diff --git a/includes/batch.inc b/includes/batch.inc
index 7011abf..46fa6cf 100644
--- a/includes/batch.inc
+++ b/includes/batch.inc
@@ -467,7 +467,7 @@ function _batch_finished() {
 
   // Clean-up the session. Not needed for CLI updates.
   if (isset($_SESSION)) {
-    unset($_SESSION['batches'][$batch['id']]);
+    unset($_SESSION['batches'][$_batch['id']]);
     if (empty($_SESSION['batches'])) {
       unset($_SESSION['batches']);
     }
