I need to trigger a script at session expire or when user closes the tab or browser

Hi
I am using a customized login and we are storing login details in session variable via script at login. Is there any event in Ignition which get trigger when session expire and also when user close the browser or tab?
I need to trigger a script at session expire or when user closes the tab or browser.