diff --git a/include/web-socket-js/web_socket.js b/include/web-socket-js/web_socket.js
index ad65dd1b5baa0b67198fa52963c4518973a2b2ae..1f040d56b9de926da15126deeb2b8c06ac890898 100755
--- a/include/web-socket-js/web_socket.js
+++ b/include/web-socket-js/web_socket.js
@@ -126,7 +126,11 @@
     // > You are trying to call recursively into the Flash Player which is not allowed.
     this.readyState = WebSocket.CLOSED;
     if (this.__timer) clearInterval(this.__timer);
-    if (this.onclose) this.onclose();
+    if (this.onclose) {
+        // Make it asynchronous so that it looks more like an actual
+        // close event
+        setTimeout(this.onclose, 1);
+    }
   };
 
   /**