Socket#onClose(): ensure transport won't stay open.

There are rare error cases when transport could stay open in the background
even if socket is closed, so it is better to always call
`this.transport.close()` in Socket#onClose as it is idempotent and
safe to call multiple times.
Make Request#cleanup() safe to call multiple times.
Cast hasAttachEvent to boolean early
Merge pull request #275 from plievone/ensure-transport-close

Ensure transport will be really closed in all cases