Fixing errors thrown after the socket is disconnected.