diff --git a/ring-buffer.cabal b/ring-buffer.cabal
--- a/ring-buffer.cabal
+++ b/ring-buffer.cabal
@@ -1,5 +1,5 @@
 name:                ring-buffer
-version:             0.2.0
+version:             0.3
 synopsis:            A concurrent, mutable ring-buffer
 description:         A concurrent, mutable ring-buffer
 homepage:            http://github.com/bgamari/ring-buffer
@@ -21,7 +21,8 @@
   build-depends:       base >=4.7 && <4.10,
                        vector >=0.10 && <0.12,
                        mtl >=2.2 && <2.3,
-                       primitive >=0.5 && <0.7
+                       primitive >=0.5 && <0.7,
+                       exceptions >=0.8 && <0.9
   hs-source-dirs:      src
   default-language:    Haskell2010
 
diff --git a/src/Data/RingBuffer.hs b/src/Data/RingBuffer.hs
--- a/src/Data/RingBuffer.hs
+++ b/src/Data/RingBuffer.hs
@@ -13,13 +13,15 @@
                        , withItems
                        ) where
 
-import Prelude hiding (length, concat)
 import qualified Data.Vector.Generic as VG
 import qualified Data.Vector.Generic.Mutable as VGM
+import Control.Applicative
 import Control.Concurrent
+import Control.Monad.Catch
 import Control.Monad.State
 import Control.Monad.Reader
 import Control.Monad.Primitive
+import Prelude hiding (length, concat)
 
 -- | A concurrent ring buffer.
 data RingBuffer v a
@@ -33,11 +35,11 @@
 type RingM m vm a = StateT RingState (ReaderT (vm (PrimState IO) a) m)
 
 -- | Atomically perform an action with the ring
-withRing :: (VG.Vector v a, MonadIO m)
+withRing :: (VG.Vector v a, MonadIO m, MonadMask m)
          => RingBuffer v a
          -> RingM m (VG.Mutable v) a r
          -> m r
-withRing rb action = do
+withRing rb action = mask_ $ do
     s <- liftIO $ takeMVar (ringState rb)
     (r, s') <- runReaderT (runStateT action s) (ringBuffer rb)
     liftIO $ putMVar (ringState rb) s'
@@ -140,7 +142,8 @@
 -- Note that no references to the vector may leak out of the action as
 -- it will later be mutated. Moreover, the items in the vector are in
 -- no particular order.
-withItems :: (MonadIO m, VG.Vector v a) => RingBuffer v a -> (v a -> m b) -> m b
+withItems :: (MonadIO m, MonadMask m, VG.Vector v a)
+          => RingBuffer v a -> (v a -> m b) -> m b
 withItems rb action = withRing rb $ do
     frozen <- liftIO $ VG.unsafeFreeze (ringBuffer rb)
     n <- length'
