diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,7 @@
+## 3.0.0.9
+
+* Clean up stream resources when websockets completes [#549](https://github.com/yesodweb/wai/pull/549)
+
 ## 3.0.0.8
 
 * Support wai 3.2
diff --git a/Network/Wai/Handler/WebSockets.hs b/Network/Wai/Handler/WebSockets.hs
--- a/Network/Wai/Handler/WebSockets.hs
+++ b/Network/Wai/Handler/WebSockets.hs
@@ -7,6 +7,7 @@
     , runWebSockets
     ) where
 
+import              Control.Exception               (bracket)
 import              Data.ByteString                 (ByteString)
 import qualified    Data.ByteString.Char8           as BC
 import qualified    Data.ByteString.Lazy            as BL
@@ -94,20 +95,20 @@
               -> IO ByteString
               -> (ByteString -> IO ())
               -> IO a
-runWebSockets opts req app src sink = do
-    stream <- WS.makeStream
-        (do
-            bs <- src
-            return $ if BC.null bs then Nothing else Just bs)
-        (\mbBl -> case mbBl of
-            Nothing -> return ()
-            Just bl -> mapM_ sink (BL.toChunks bl))
-
-    let pc = WS.PendingConnection
-                { WS.pendingOptions     = opts
-                , WS.pendingRequest     = req
-                , WS.pendingOnAccept    = \_ -> return ()
-                , WS.pendingStream      = stream
-                }
+runWebSockets opts req app src sink = bracket mkStream WS.close (app . pc)
+  where
+    mkStream =
+        WS.makeStream
+            (do
+                bs <- src
+                return $ if BC.null bs then Nothing else Just bs)
+            (\mbBl -> case mbBl of
+                Nothing -> return ()
+                Just bl -> mapM_ sink (BL.toChunks bl))
 
-    app pc
+    pc stream = WS.PendingConnection
+        { WS.pendingOptions     = opts
+        , WS.pendingRequest     = req
+        , WS.pendingOnAccept    = \_ -> return ()
+        , WS.pendingStream      = stream
+        }
diff --git a/wai-websockets.cabal b/wai-websockets.cabal
--- a/wai-websockets.cabal
+++ b/wai-websockets.cabal
@@ -1,5 +1,5 @@
 Name:                wai-websockets
-Version:             3.0.0.8
+Version:             3.0.0.9
 Synopsis:            Provide a bridge between WAI and the websockets package.
 License:             MIT
 License-file:        LICENSE
