title: "un-register" a doParallel cluster
body: <p>If I run <code>foreach... %dopar%</code> without registering a cluster, foreach raises a warning, and executes the code sequentially:</p>
  
  <pre><code>library("doParallel")
  foreach(i=1:3) %dopar%
    sqrt(i)
  </code></pre>
  
  <p>Yields:</p>
  
  <pre><code>Warning message:
  executing %dopar% sequentially: no parallel backend registered 
  </code></pre>
  
  <p>However, if I run this same code after starting, registering, and stopping a cluster, it fails:</p>
  
  <pre><code>cl &lt;- makeCluster(2)
  registerDoParallel(cl)
  stopCluster(cl)
  rm(cl)
  foreach(i=1:3) %dopar%
    sqrt(i)
  </code></pre>
  
  <p>Yields:</p>
  
  <pre><code>Error in summary.connection(connection) : invalid connection
  </code></pre>
  
  <p>Is there an opposite of <code>registerDoParallel()</code> that cleans up the cluster registration?  Or am I stuck with the ghost of the old cluster until I re-start my R session?</p>
  
  <p>/edit: some googling reveals the <code>bumphunter:::foreachCleanup()</code> function in the <a href="http://www.bioconductor.org/packages/release/bioc/html/bumphunter.html">bumphunter</a> Biocondoctor package:</p>
  
  <pre><code>function () 
  {
      if (exists(".revoDoParCluster", where = doParallel:::.options)) {
          if (!is.null(doParallel:::.options$.revoDoParCluster)) 
              stopCluster(doParallel:::.options$.revoDoParCluster)
          remove(".revoDoParCluster", envir = doParallel:::.options)
      }
  }
  &lt;environment: namespace:bumphunter&gt;
  </code></pre>
  
  <p>However, this function doesn't seem to fix the problem.</p>
  
  <pre><code>library(bumphunter)
  cl &lt;- makeCluster(2)
  registerDoParallel(cl)
  stopCluster(cl)
  rm(cl)
  bumphunter:::foreachCleanup()
  foreach(i=1:3) %dopar%
    sqrt(i)
  </code></pre>
  
  <p>Where does foreach keep the information on the registered cluster?</p>