You cannot know when somebody closes a query window. You can use the ON CLOSE event, /help on close, to detect when you close a window however. In the case of DCC it will detect when the connection is terminated.

Regards,