diff --git a/examples/iterforkio.hs b/examples/iterforkio.hs
--- a/examples/iterforkio.hs
+++ b/examples/iterforkio.hs
@@ -8,7 +8,6 @@
 
 import Control.Concurrent
 import Control.Concurrent.Async
-import Control.Exception
 import Data.Default
 
 import Database.LevelDB.Base
@@ -16,13 +15,13 @@
 import qualified Data.ByteString.Char8 as BS
 
 main :: IO ()
-main = bracket (open "/tmp/leveltest" def{ createIfMissing = True }) close $ \ db -> do
+main = withDB "/tmp/leveltest" def{ createIfMissing = True } $ \ db -> do
 
     let xs = [1..100] :: [Int]
 
     write db def (map (\ x -> Put (BS.pack . show $ x) "") xs)
 
-    bracket (createIter db def) releaseIter $ \ iter -> do
+    withIter db def $ \ iter -> do
         _   <- iterFirst iter
         lck <- newMVar iter
         es  <- mapConcurrently (getEntry lck) xs
diff --git a/leveldb-haskell.cabal b/leveldb-haskell.cabal
--- a/leveldb-haskell.cabal
+++ b/leveldb-haskell.cabal
@@ -1,5 +1,5 @@
 name:                leveldb-haskell
-version:             0.5
+version:             0.5.1
 synopsis:            Haskell bindings to LevelDB
 homepage:            http://github.com/kim/leveldb-haskell
 bug-reports:         http://github.com/kim/leveldb-haskell/issues
diff --git a/src/Data/Stream/Monadic.hs b/src/Data/Stream/Monadic.hs
--- a/src/Data/Stream/Monadic.hs
+++ b/src/Data/Stream/Monadic.hs
@@ -225,7 +225,7 @@
             Yield x s' -> Yield x (Just s')
 {-# INLINE [0] snoc #-}
 
--- | Unlike 'Data.List.head', this function does not diverge if the 'Stream is
+-- | Unlike 'Data.List.head', this function does not diverge if the 'Stream' is
 -- empty. Instead, 'Nothing' is returned.
 head :: Monad m => Stream m a -> m (Maybe a)
 head (Stream next s0) = loop =<< s0
diff --git a/src/Database/LevelDB/Base.hs b/src/Database/LevelDB/Base.hs
--- a/src/Database/LevelDB/Base.hs
+++ b/src/Database/LevelDB/Base.hs
@@ -30,6 +30,7 @@
     , defaultWriteOptions
 
     -- * Basic Database Manipulations
+    , withDB
     , open
     , put
     , delete
@@ -97,6 +98,14 @@
             return db
 
     addFinalizer ref = void . mkWeakIORef ref
+
+-- | Run an action with a 'DB'.
+--
+-- > withDB path opts = bracket (open path opts) unsafeClose
+--
+-- Note that the 'DB' handle will be released promptly when this function exits.
+withDB :: (MonadMask m, MonadIO m) => FilePath -> Options -> (DB -> m a) -> m a
+withDB path opts = bracket (open path opts) (liftIO . unsafeClose)
 
 -- | Run an action with a 'Snapshot' of the database.
 withSnapshot :: (MonadMask m, MonadIO m) => DB -> (Snapshot -> m a) -> m a
diff --git a/src/Database/LevelDB/Internal.hs b/src/Database/LevelDB/Internal.hs
--- a/src/Database/LevelDB/Internal.hs
+++ b/src/Database/LevelDB/Internal.hs
@@ -1,4 +1,6 @@
 {-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE CPP             #-}
+
 -- |
 -- Module      : Database.LevelDB.Internal
 -- Copyright   : (c) 2012-2013 The leveldb-haskell Authors
@@ -17,7 +19,7 @@
 
     , unsafeClose
 
-    -- * "Smart" constructors and deconstructors
+    -- * \"Smart\" constructors and deconstructors
     , freeCReadOpts
     , freeComparator
     , freeFilterPolicy
@@ -95,9 +97,20 @@
 -- will segfault (internally, leveldb performs a @delete@ on the pointer).
 unsafeClose :: DB -> IO ()
 unsafeClose (DB db_ptr opts_ptr ref) = do
-    alive <- atomicModifyIORef' ref ((,) False)
+    alive <- modify ref ((,) False)
     when alive $
         c_leveldb_close db_ptr `finally` freeOpts opts_ptr
+
+modify :: IORef a -> (a -> (a,b)) -> IO b
+#if MIN_VERSION_base(4,6,0)
+modify = atomicModifyIORef'
+#else
+modify ref f = do
+    b <- atomicModifyIORef ref
+            (\x -> let (a, b) = f x
+                    in (a, a `seq` b))
+    b `seq` return b
+#endif
 
 mkOpts :: Options -> IO Options'
 mkOpts Options{..} = do
