diff --git a/Network/AMQP.hs b/Network/AMQP.hs
--- a/Network/AMQP.hs
+++ b/Network/AMQP.hs
@@ -541,6 +541,7 @@
                     connChannels :: (MVar (IM.IntMap (Channel, ThreadId))), --open channels (channelID => (Channel, ChannelThread))
                     connMaxFrameSize :: Int, --negotiated maximum frame size
                     connClosed :: MVar (Maybe String),
+                    connClosedLock :: MVar (), -- used by closeConnection to block until connection-close handshake is complete
                     connWriteLock :: MVar (), -- to ensure atomic writes to the socket
                     lastChannelID :: MVar Int --for auto-incrementing the channelIDs
                 }
@@ -623,7 +624,8 @@
     lastChanID <- newMVar 0
     cClosed <- newMVar Nothing
     writeLock <- newMVar ()
-    let conn = Connection sock connChannels (fromIntegral maxFrameSize) cClosed writeLock lastChanID
+    ccl <- newEmptyMVar
+    let conn = Connection sock connChannels (fromIntegral maxFrameSize) cClosed ccl writeLock lastChanID
     
     --spawn the connectionReceiver
     forkIO $ CE.finally (connectionReceiver conn) 
@@ -635,6 +637,9 @@
                 --kill all channel-threads
                 withMVar connChannels $ \cc -> mapM_ (\c -> killThread $ snd c) $ IM.elems cc
                 withMVar connChannels $ \cc -> return $ IM.empty
+                
+                -- mark connection as closed, so all pending calls to 'closeConnection' can now return
+                tryPutMVar ccl ()
                 )
 
     return conn
@@ -651,7 +656,8 @@
         True)))   --insist; True because we don't support redirect yet
 
         
- 
+        
+
 -- | closes a connection
 closeConnection :: Connection -> IO ()
 closeConnection c = do
@@ -668,7 +674,9 @@
             --do nothing if connection is already closed
             return ()
         ) 
-    -- connection_close_ok will be handled in the "connectionReceiver" method above
+   
+    -- wait for connection_close_ok by the server
+    readMVar $ connClosedLock c
     return ()
     
     
diff --git a/amqp.cabal b/amqp.cabal
--- a/amqp.cabal
+++ b/amqp.cabal
@@ -1,5 +1,5 @@
 Name:                amqp
-Version:             0.2.1
+Version:             0.2.2
 Synopsis:            Client library for AMQP servers (currently only RabbitMQ)
 Description:         Client library for AMQP servers (currently only RabbitMQ)
 License:             BSD3
diff --git a/examples/ExampleProducer.hs b/examples/ExampleProducer.hs
--- a/examples/ExampleProducer.hs
+++ b/examples/ExampleProducer.hs
@@ -28,6 +28,7 @@
                     
                 
     closeConnection conn
+    
 
 
     
