       hyperclientDestroy hc
       mapM_ (\(HandleCallback cont) -> cont Nothing) $ Map.elems handles 
       putMVar c (Nothing, Map.empty)
+
+-- | Wait for graceful termination of all outstanding requests and
+-- then close the connection.
+--
+-- /Note:/ If it is necessary to have this operation complete quickly
+-- and outstanding requests are not needed, then use 'forceClose'.
+close :: Client -> IO ()
+close client@(getClient -> c) = do
+  clientData <- takeMVar c
+  case clientData of
+    (Nothing, _)        -> error "HyperDex client error - cannot close a client connection twice."
+    (Just hc, handles)  -> do
+      case Map.null handles of
+        True  -> do
+          hyperclientDestroy hc
+          putMVar c (Nothing, Map.empty)
+        False -> do
+          -- Have to put it back in order to run loopClient
+          (_, newHandles) <- handleLoop hc handles
+          putMVar c (Just hc, newHandles)
+          close client
 
 doExponentialBackoff :: Int -> Double -> (Int, BackoffMethod)
 doExponentialBackoff b x = 

-- is closed ought to return a 'ReturnCode' indicating the failure
-- condition, but the behavior is ultimately undefined. Any pending
-- requests should be disregarded. 
close :: Client -> IO ()
close (getClient -> c) = do
  clientData <- takeMVar c
  case clientData of
    (Nothing, _)        -> error "HyperDex client error - cannot close a client connection twice."

instance Default ConnectOptions where
  def =
    ConnectOptions
      { connectionBackoff = BackoffYield -- 10 * 2^n
      , connectionBackoffCap = Just 50000           -- 0.05 seconds.
      }

-- | Sane defaults for HyperDex connection options.
