Add the following script block to your xpage. Preview the same and close it. Once you close your XPage you will get a prompt which depicts the triggering of the onUnload event in xpages.
alert('I run on window unload');
A little bit of client techniques to include server side scripts will also work here.
Hope this helps:)