diff --git a/hasql-pool.cabal b/hasql-pool.cabal
--- a/hasql-pool.cabal
+++ b/hasql-pool.cabal
@@ -1,7 +1,7 @@
 name:
   hasql-pool
 version:
-  0.5.1
+  0.5.2
 category:
   Hasql, Database, PostgreSQL
 synopsis:
diff --git a/library/Hasql/Pool/ResourcePool.hs b/library/Hasql/Pool/ResourcePool.hs
--- a/library/Hasql/Pool/ResourcePool.hs
+++ b/library/Hasql/Pool/ResourcePool.hs
@@ -11,7 +11,7 @@
 withResourceOnEither :: Pool resource -> (resource -> IO (Either failure success)) -> IO (Either failure success)
 withResourceOnEither pool act = mask_ $ do
   (resource, localPool) <- takeResource pool
-  failureOrSuccess <- act resource
+  failureOrSuccess <- act resource `onException` destroyResource pool localPool resource
   case failureOrSuccess of
     Right success -> do
       putResource localPool resource
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -15,15 +15,15 @@
     it "releases a spot in the pool when there is an error" $ do
       pool <- acquire (1, 1, "host=localhost port=5432 user=postgres dbname=postgres")
       let
-        statement = Statement.Statement "" Encoders.unit Decoders.unit True
+        statement = Statement.Statement "" Encoders.noParams Decoders.noResult True
         session = Session.statement () statement
         in do
           use pool session `shouldNotReturn` (Right ())
       let
         session = let
           statement = let
-            decoder = Decoders.singleRow (Decoders.column Decoders.int8)
-            in Statement.Statement "SELECT 1" Encoders.unit decoder True
+            decoder = Decoders.singleRow (Decoders.column (Decoders.nonNullable Decoders.int8))
+            in Statement.Statement "SELECT 1" Encoders.noParams decoder True
           in Session.statement () statement
         in do
           use pool session `shouldReturn` (Right 1)
