Make sure that we don't attempt to write to ended sockets. For now this works, but promise cancellation would be better.