@Override
  protected void runOneIteration() {
    if (!JobMetadata.isInitialized()) {
      return;
    }
    monitor.debug(() -> "polling for job to check cancellation");
    PortabilityJob currentJob = store.findJob(JobMetadata.getJobId());
    switch (currentJob.state()) {
      case CANCELED:
        monitor.info(
            () -> String.format("Job %s is canceled", JobMetadata.getJobId()),
            EventCode.WORKER_JOB_CANCELED);
        dtpInternalMetricRecorder.cancelledJob(
            JobMetadata.getDataType(),
            JobMetadata.getExportService(),
            JobMetadata.getImportService(),
            JobMetadata.getStopWatch().elapsed());
        monitor.flushLogs();
        store.abandonJob(JobMetadata.getJobId(), PortabilityJob.State.CANCELED.toString());
        System.exit(0);
        break;
      case ERROR:
        monitor.severe(
            () -> String.format("Job %s is errored", JobMetadata.getJobId()),
            EventCode.WATCHING_SERVICE_JOB_ERRORED);
        recordGeneralMetric(PortabilityJob.State.ERROR.toString());
        monitor.flushLogs();
        store.abandonJob(JobMetadata.getJobId(), PortabilityJob.State.ERROR.toString());
        System.exit(0);
        break;
      case PREEMPTED:
        monitor.info(
            () -> String.format("Job %s is preempted", JobMetadata.getJobId()),
            EventCode.WATCHING_SERVICE_JOB_PREEMPTED);
        recordGeneralMetric(PortabilityJob.State.PREEMPTED.toString());
        monitor.flushLogs();
        store.abandonJob(JobMetadata.getJobId(), PortabilityJob.State.PREEMPTED.toString());
        System.exit(0);
        break;
      default:
        monitor.debug(
            () ->
                String.format(
                    "Job %s is not canceled or errored or preempted", JobMetadata.getJobId()));
    }
  }
A service that polls storage to see if a job is canceled, if it is it kills the binary.
portability-transfer/src/main/java/org/datatransferproject/transfer/JobCancelWatchingService.java