Ensure transport will be really closed in all cases

There are error cases (related to failed open) where onClose is called directly and transport may stay open in the background, detached from closed socket.

Also added missing null check in Request#cleanup(). (Or check both with `null == this.xhr`, your call)
Also cast hasAttachEvent to boolean to avoid mistakes later.