diff --git a/gnsq/stream/stream.py b/gnsq/stream/stream.py
index <HASH>..<HASH> 100644
--- a/gnsq/stream/stream.py
+++ b/gnsq/stream/stream.py
@@ -104,7 +104,6 @@ class Stream(object):
 
         self.state = DISCONNECTED
         self.queue.put(StopIteration)
-        self.socket.close()
 
     def send_loop(self):
         for data, result in self.queue:
@@ -122,6 +121,8 @@ class Stream(object):
             except Exception as error:
                 result.set_exception(error)
 
+        self.socket.close()
+
     def upgrade_to_tls(
         self,
         keyfile=None,
Close socket only after all the messages have been sent.