Throw IOException when writing closed socket.