Set up a timeout handler after connection

It seems that timeouts were only handled while connecting, but not after.
Reuse the 'close' callback for 'timeout' as well, which flushes out all
pending callbacks.