Close window by clicking anywhere

Is it possible to close a window by a mouseclick outside the window?

I open a window in a function with this statement:

id = dhxWins.createWindow(id, x, y, w, h);


function doOnLoad(){ dhxWins = new dhtmlXWindows(); dhxWins.enableAutoViewport(true); dhxWins.attachViewportTo("winVP"); dhxWins.setImagePath("../dhtmlxWindows/codebase/imgs/"); w1 = dhxWins.createWindow("w1",0, 0, 362, 457); }

<div id="winVP" style=" height: 100%; overflow: auto;"></div> <input type="button" onclick="w1.close()" value="close window">