diff --git a/support/node-websocket-client/lib/websocket.js b/support/node-websocket-client/lib/websocket.js
index <HASH>..<HASH> 100644
--- a/support/node-websocket-client/lib/websocket.js
+++ b/support/node-websocket-client/lib/websocket.js
@@ -494,6 +494,13 @@ var WebSocket = function(url, proto, opts) {
             return function(req, s, head) {
                 stream = s;
 
+                if (readyState == CLOSED) {
+                    stream.end();
+                    stream.destroy();
+                    stream = undefined;
+                    return;
+                }
+
                 stream.on('data', function(d) {
                     if (d.length <= 0) {
                         return;
patched to properly shut down when a finishClose call is made during connection establishment