Handle cases where the socket is closed before being passed to the server

If the stream is not readable it means that other end has sent the FIN packet.
When this happens we can end the write site of the socket and bail out.

I don't know if this approach has side effects but it seems to work.