This is not something that is achievable. You can get pretty close by registering a JavaScript function that is fired on the window onunload event which can call code to invalidate the session, but this can not be guaranteed to fire in all situations (e.g. browser process killed via task manager, power cable being pulled etc.). Safer and easier is to include a session timeout.