             return _resource.readUnsignedShort();
         }
 
-        override public function readBytes(bytes : ByteArray, offset : uint = 0, length : uint = 0) : void {
+        override public function readBytes(bytes : ByteArray,
+            offset : uint = 0, length : uint = 0) : void
+        {
             if (!holaManaged)
                 return super.readBytes(bytes, offset, length);
             _resource.readBytes(bytes, offset, length);
         }
 
         override public function close() : void {
-            if (holaManaged && reqs[req_id])
-                _trigger('abortFragment', {req_id: req_id});
+            if (holaManaged)
+            {
+                if (reqs[req_id])
+                    _trigger('abortFragment', {req_id: req_id});
+                WorkerUtils.removeEventListener(HEvent.WORKER_MESSAGE, onmsg);
+            }
             if (super.connected)
                 super.close();
             _connected = false;

    import flash.utils.Timer;
    import org.hola.ZErr;
    import org.hola.Base64;
    import org.mangui.hls.loader.FragmentLoader;

    public dynamic class JSURLStream extends URLStream {
        private var _connected : Boolean;
        private var _resource : ByteArray = new ByteArray();
        public var holaManaged:Boolean = false;
        public static var jsApiInited:Boolean = false;
        public static var reqCount:Number = 0;

        }

        protected function resourceLoadingError() : void {
            delete reqs[req_id];
            dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR));
        }

        protected function resourceLoadingSuccess() : void {
            delete reqs[req_id];
            dispatchEvent(new Event(Event.COMPLETE));
        }
    }
}
