Addresses #179 where server crashes due to an attempt to send messages on a closed socket