Shutdown function: Stores the current batch data for the next request.
drupal_register_shutdown_function()
function _batch_shutdown() {
if ($batch = batch_get()) {
db_update('batch')
->fields(array(
'batch' => serialize($batch),
))
->condition('bid', $batch['id'])
->execute();
}
}