You have to understand that because of the disconnected nature of the web, when user closes the browser window from the X button, the server knows nothing of it...No event send to the server, whatsoever...
The server-side events of session-end and application-end will be launched when time will come, but the data from the client lost already at that point...
As you are talking about the login status, you should store that status upon change, so when user finishes the login store the status, and then let user play with the page...
If you mean to set login status to 'off' when user closing the browser, you should use the article below, but be sure to do the same on session-end too as all the solutions in that article have no 100% success...
How to end user session when browser closed[
^]
Execute server side code on close of a browser[
^]