Fix write completion blocks not executed on socket closed by remote peer