handle server disconnects properly