wait for buffer to be drained before closing

When a socket sends packets and closes while upgrading a transport, those packets remain to be treated.
I changed to wait the drain event before actual closing on that situation. Sorry for the delay.

related issues: https://github.com/Automattic/engine.io/issues/284 https://github.com/Automattic/engine.io-client/pull/324