How to close dhtmlxWindow with attached Dataview

I’m having problems trying to close a dhtmlx window that has a dataview attached to it.

When the user clicks on one of the items in the dataview the window should close (and perform other actions).

My code below allows the window to close but throws a JS error “Uncaught TypeError: Cannot read property ‘exists’ of null”.

dhxWins.unload();
dhxWins = w1 = null;

I’ve tried various ways of closing the window but if the dataview click is used to initiate the close code then the error is thrown. If a button outside the window is used the run the same code no error is thrown. Also if I don’t attach the dataview and use an HTML button within the window to run the code no error occurs.

This seems like a bug to me but I’d really appreciate some help if I’m missing something.

You can view my simplified code here - posmarket.com.au/testlayout.asp

Hello
You can try to use onBeforeSelect instead onItemClick (dataview triуs to select nonexistent item) or call unload with timeout
The nest way will be hide() window