more robust logging out