Logout while closing window