@@ -323,14 +323,16 @@ startServiceProcesses node = do
323323-- | Force-close a local node, killing all processes on that node.
324324closeLocalNode :: LocalNode -> IO ()
325325closeLocalNode node = do
326− modifyMVar_ (localState node) $ const $ return LocalNodeClosed
327− withValidLocalState (localState node) $ \vst ->
328− forM_ (vst ^. localProcesses) $ \lproc ->
329− -- Semantics of 'throwTo' guarantee that target thread will get delivered
330− -- an exception. Therefore, target thread will be killed eventually and
331− -- that's as good as we can do. No need to wait for thread to actually
332− -- finish dying.
333− killThread (processThread lproc)
326+ modifyMVar_ (localState node) $ \st -> case st of
327+ LocalNodeValid vst -> do
328+ forM_ (vst ^. localProcesses) $ \lproc ->
329+ -- Semantics of 'throwTo' guarantee that target thread will get
330+ -- delivered an exception. Therefore, target thread will be killed
331+ -- eventually and that's as good as we can do. No need to wait for
332+ -- thread to actually finish dying.
333+ killThread (processThread lproc)
334+ return LocalNodeClosed
335+ LocalNodeClosed -> return LocalNodeClosed
334336 NT.closeEndPoint (localEndPoint node)
335337
336338-- | Run a process on a local node and wait for it to finish