The stop is asynchronous and will wait until the current transition / suspendTransition ends before effectively stopping.
This will force the executorService to be Value
@param context the stop context.
171918
@Override
    public void stop(StopContext context) {
        Runnable asyncStop = () -> {
            synchronized (stopLock) {
                controlledProcessStateServiceSupplier.get().removePropertyChangeListener(propertyChangeListener);
                SuspendController controller = suspendControllerSupplier != null ? suspendControllerSupplier.get() : null;
                if (controller != null) {
                    controller.removeListener(operationListener);
                }
                runningState = null;
                try {
                    listener.cleanup();
                } catch (RuntimeException t) {
                    CoreManagementLogger.ROOT_LOGGER.processStateCleanupError(t, name);
                } finally {
                    context.complete();
                }
            }
        };
        final ExecutorService executorService = executorServiceSupplier.get();
        try {
            try {
                executorService.execute(asyncStop);
            } catch (RejectedExecutionException e) {
                asyncStop.run();
            }
        } finally {
            context.asynchronous();
        }
    }
1150754
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1975")
  public static Status statusFromCancelled(Context context) {
    Preconditions.checkNotNull(context, "context must not be null");
    if (!context.isCancelled()) {
      return null;
    }

    Throwable cancellationCause = context.cancellationCause();
    if (cancellationCause == null) {
      return Status.CANCELLED.withDescription("io.grpc.Context was cancelled without error");
    }
    if (cancellationCause instanceof TimeoutException) {
      return Status.DEADLINE_EXCEEDED
          .withDescription(cancellationCause.getMessage())
          .withCause(cancellationCause);
    }
    Status status = Status.fromThrowable(cancellationCause);
    if (Status.Code.UNKNOWN.equals(status.getCode())
        && status.getCause() == cancellationCause) {
      // If fromThrowable could not determine a status, then
      // just return CANCELLED.
      return Status.CANCELLED.withDescription("Context cancelled").withCause(cancellationCause);
    }
    return status.withCause(cancellationCause);
  }
947079
void stop() {
    stopAsync();
    try {
      // stopperThread is not null for sure
      // join() does nothing if thread already finished
      stopperThread.join();
      lifecycle.tryToMoveTo(Lifecycle.State.STOPPED);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
    exit.exit(0);
  }
986754
public void contextDestroyed(ServletContextEvent sce)
    {
        synchronized (Publisher.class)
        {
            if (Publisher.worker != null)
            {
                Publisher.worker.interrupt();
            }
        }
    }
483190
public final void contextDestroyed(final ServletContextEvent sce) {
		// Stop the TciIpServer
		if (this.tcpIpServer != null) {
			this.tcpIpServer.stop();
		}

		// Stop the JmxServer
		if (this.jmxServer != null) {
			this.jmxServer.stop();
		}

		// Stop the SshServer
		if (this.sshServer != null) {
			try {
				this.sshServer.stop();
			} catch (InterruptedException e) {
				LaunchingMessageKind.ESSH0002.format(e);
			}
		}
	}
154673
protected void deactivate(ComponentContext context) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
            Tr.event(tc, "deactivate", context);
        authDataServiceRef.deactivate(context);
        deferrableSchedXSvcRef.deactivate(context);
        execSvcRef.deactivate(context);
        nonDeferrableSchedXSvcRef.deactivate(context);
        rrsXAResFactorySvcRef.deactivate(context);
        variableRegistrySvcRef.deactivate(context);
    }
113166
protected void deactivate(ComponentContext context) throws Exception {

        contextProviders.deactivate(context);
        bvalRef.deactivate(context);
        tranInflowManagerRef.deactivate(context);
        tranSyncRegistryRef.deactivate(context);
        jcaSecurityContextRef.deactivate(context);

        latch.countDown();
        latches.remove(resourceAdapterID, latch);

        FutureMonitor futureMonitor = futureMonitorSvc;
        Future<Boolean> future = appsStoppedFuture.getAndSet(null);
        if (futureMonitor != null && future != null) {
            futureMonitor.onCompletion(future, new CompletionListener<Boolean>() {
                @Override
                public void successfulCompletion(Future<Boolean> future, Boolean result) {
                    stopResourceAdapter();
                }

                @Override
                public void failedCompletion(Future<Boolean> future, Throwable t) {
                    stopResourceAdapter();
                }
            });
        } else {
            stopResourceAdapter();
        }
    }
519607
protected void deactivate(ComponentContext context) {
        destinationRef.deactivate(context);
        bootstrapContextRef.deactivate(context);
        rrsXAResFactorySvcRef.deactivate(context);
    }
806826
protected void deactivate(ComponentContext context) {
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(this, tc, "deactivate");

        lock.writeLock().lock();
        try {
            if (isInitialized) {
                if (classloader != null) {
                    if (isDerbyEmbedded.get())
                        shutdownDerbyEmbedded();
                    classloader = null;
                }
                for (Iterator<Class<? extends CommonDataSource>> it = introspectedClasses.iterator(); it.hasNext(); it.remove())
                    Introspector.flushFromCaches(it.next());
                isInitialized = false;
            }
        } finally {
            lock.writeLock().unlock();
        }

        if (trace && tc.isEntryEnabled())
            Tr.exit(this, tc, "deactivate");
    }
890258
protected void ensureTransitionAllowed(CmmnActivityExecution execution, CaseExecutionState expected, CaseExecutionState target, String transition) {
    String id = execution.getId();

    CaseExecutionState currentState = execution.getCurrentState();

    // the state "suspending" or "terminating" will set immediately
    // inside the corresponding AtomicOperation, that's why the
    // previous state will be used to ensure that the transition
    // is allowed.
    if (execution.isTerminating() || execution.isSuspending()) {
      currentState = execution.getPreviousState();
    }

    // is the case execution already in the target state
    if (target.equals(currentState)) {
      throw LOG.isAlreadyInStateException(transition, id, target);

    } else
    // is the case execution in the expected state
    if (!expected.equals(currentState)) {
      throw LOG.unexpectedStateException(transition, id, expected, currentState);
    }
  }
1100494
@Activate
    protected void activate(ComponentContext context) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
            Tr.event(tc, "activate", context);
    }
403377
private static final void stopBroker() {
		AbstractApplicationContext instance = context.getAndSet(null);
		if (instance != null) {
			Thread safetyTimer = new Thread() {

				public void run() {
					try {
						Thread.sleep(15000);
						Runtime.getRuntime().halt(1);
					} catch (Throwable ignored) {
					}
				}

			};
			safetyTimer.setDaemon(true);
			safetyTimer.start();
			try {
				instance.stop();
			} catch (Throwable ignored) {
			}
			try {
				Thread.sleep(600);
			} catch (Throwable interrupted) {
			}
			Runtime.getRuntime().halt(0);
		}
	}
935719
public void suspend() {
    if (suspension.compareAndSet(null, new CountDownLatch(1))) {
      try {
        suspendBarrier.await();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      } catch (BrokenBarrierException e) {
        LOG.error("Exception during suspend: " + flowletContext, e);
      }
    }
  }
248362
private boolean handlePausedFlowAfterStep(Execution execution) throws InterruptedException {
        String branchId = execution.getSystemContext().getBranchId();
        PauseReason reason = null;
        ExecutionSummary execSummary = pauseService.readPausedExecution(execution.getExecutionId(), branchId);
        if (execSummary != null && execSummary.getStatus().equals(ExecutionStatus.PENDING_PAUSE)) {
            reason = execSummary.getPauseReason();
        }
        if (reason != null) { // need to pause the execution
            pauseFlow(reason, execution);
            return true;
        }
        return false;
    }
1343251
public void stop()
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "stop");
        ivIsInitialized = false;
        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "stop");
    }
817167
public static void suspend(long intervalAsMillis,
            Supplier<Boolean> suspendConditionSupplier) {
        if (!suspendConditionSupplier.get())
            return;
        log.warn("Start Suspending !!!");
        long startTimeMillis = System.currentTimeMillis();
        while (suspendConditionSupplier.get())
            sleep(intervalAsMillis);
        log.warn("Stop Suspending Over {} ms",
                System.currentTimeMillis() - startTimeMillis);
    }
537201
public void run(Context context) throws IOException, InterruptedException {
    setup(context);
    while (context.nextKey()) {
      context.progress();
      reduce(context.getCurrentKey(), context.getValues(), context);
    }
    cleanup(context);
  }