handle socket disconnect gracefully