Fix clear timeout on channel close

Timeout was being cleared on the closing event. This caused timeout to
be cleared before the socket buffer was flushed. Also since #67aa11b,
the closing event is being fired only when the socket is gracefully
closed, not when being forcefully closed due to an error, which
prevented timeout from being cleared when an error occured. This
caused the error callback to be called twice when a non-timeout error
occured.
Merge branch 'timeout-memory-leak'