code: private void interruptGracefully() throws IOException {
      LOG.info("Attempting graceful interruption of job " + this.jobContext.getJobId());
  
      this.fs.createNewFile(this.interruptPath);
  
      long waitTimeStart = System.currentTimeMillis();
      while (!this.job.isComplete() && System.currentTimeMillis() < waitTimeStart + 30 * 1000) {
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ie) {
          break;
        }
      }
  
      if (!this.job.isComplete()) {
        LOG.info("Interrupted job did not shut itself down after timeout. Killing job.");
        this.job.killJob();
      }
    }
docs: Attempt a gracious interruption of the running job