public function pause(DeliveryExecution $deliveryExecution, $reason = null)
    {
        $executionState = $deliveryExecution->getState()->getUri();
        $result = false;

        if (ProctoredDeliveryExecution::STATE_TERMINATED !== $executionState && ProctoredDeliveryExecution::STATE_FINISHED !== $executionState) {
            $session = $this->getTestSessionService()->getTestSession($deliveryExecution);
            $data = [
                'reason' => $reason,
                'timestamp' => microtime(true),
                'context' => $this->getContext($deliveryExecution),
            ];
            $this->setState($deliveryExecution, ProctoredDeliveryExecution::STATE_PAUSED);
            if ($session) {
                $data['itemId'] = $this->getCurrentItemId($deliveryExecution);
                if ($session->getState() !== AssessmentTestSessionState::SUSPENDED) {
                    $session->suspend();
                    $this->getTestSessionService()->persist($session);
                }
                $this->getServiceLocator()->get(ExtendedStateService::SERVICE_ID)->persist($session->getSessionId());
            }
            $this->getDeliveryLogService()->log($deliveryExecution->getIdentifier(), 'TEST_PAUSE', $data);
            $result = true;
        }

        return $result;
    }