code: public function cancel($ticket, $force = false)
      {
          $job = $this->findJob($ticket);
  
          if (Status::isTerminated($job->getStatus())) {
              return false;
          }
  
          $isProcessing = $job->getStatus() == Status::PROCESSING();
          $status       = $force ? Status::CANCELLED() : ($isProcessing ? Status::CANCELLING() : Status::CANCELLED());
  
          $this->helper->updateJob($job, $status);
          $this->jobManager->save($job);
  
          if ($force) {
              $this->locker->release($job->getTicket());
          }
  
          if (!$isProcessing || $force) {
              $this->dispatcher->dispatch(JobEvents::JOB_TERMINATED, new TerminationEvent($job));
              $message = $force ? 'Forced cancellation of job ' : 'Cancelled job ';
              $this->logger->info($message . $job->getTicket());
          } else {
              $this->logger->info('Request cancellation of job ' . $job->getTicket());
          }
  
          return $job;
      }
docs: {@inheritdoc}