code: public void blockTillTerminated() {
      while (!runState.compareAndSet(State.IDLE, State.REMOVED)) {
        // wait and retry
        LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
        if (Thread.currentThread().isInterrupted()) {
          runState.set(State.REMOVED);
          return;
        }
      }
    }
docs: Unschedule next launched, and wait for the current task to complete before closing it.