Add handling of disconnection