fix #36. Enable calling socket.end after socket is closed