use window.beforeunload if available, and try to log out if users close the window