Better disconnect handling for client