Handle disconnects gracefully