Use a timer for logout timeouts.

If the server fails to respond after five seconds we'll log out anyway.
Removed incorrect check.

If the socket is closed at this time we should definitely change the
state to disconnected.