If I understand you correctly, you want to run a script as they close the browser? Because your system cannot ever know if they have already closed it.
In order to do this, you'll need to have an event notification (Javascript) that calls a php script on unload of the page.
John