Throw IOException when writing closed socket.

@marco-c Why need this temp fix (3d3364154ad6e430bf823ebece03be4a52218092);