Fix #161 - send throws an exception if the socket is closed

Comments appreciated