Manager/ProcessManager.php
protected function finalize(TaskConfiguration $taskConfiguration): void
    {
        $task = $taskConfiguration->getTask();
        if ($task instanceof FinalizableTaskInterface) {
            $this->taskConfiguration = $taskConfiguration;
            $state = $taskConfiguration->getState();
            try {
                $task->finalize($taskConfiguration->getState());
            } catch (\Throwable $e) {
                $logContext = ['exception' => $e];
                $this->taskLogger->critical($e->getMessage(), $logContext);
                $state->stop($e);
            }
            $this->handleState($state);
            $this->taskConfiguration = null;
        }
    }
protected function finalize(TaskConfiguration $taskConfiguration): void
    {
        $task = $taskConfiguration->getTask();
        if ($task instanceof FinalizableTaskInterface) {
            $this->taskConfiguration = $taskConfiguration;
            $state = $taskConfiguration->getState();
            try {
                $task->finalize($taskConfiguration->getState());
            } catch (\Throwable $e) {
                $logContext = ['exception' => $e];
                $this->taskLogger->critical($e->getMessage(), $logContext);
                $state->stop($e);
            }
            $this->handleState($state);
            $this->taskConfiguration = null;
        }
    }
@param TaskConfiguration $taskConfiguration

@throws \RuntimeException