Most browsers support an 'onbeforeunload' event where you can display a warning message if that is what you want.
You can also try trapping the 'onunload' event and have it send a Ajax style message to the server -- however at this point you cannot prevent the closure from happening.
Regardless of what you do you need to consider that the browser being closed may be due to circumstances beyond the control of the user or browser. Power failure, reboot, forced close, loss of connection, etc.. are all reasons that your browser connection may be terminated.
What I would suggest is you create some form of background polling between the browser and PxPlus where you can consider no polls for a period of time as a disconnect. This s what iNomads does in order to help assure the browser is still connected as well as setting an 'onbeforeunload' event handler.