@Override
    public void cancel() {
        synchronized (monitor) {
            if (!periodicExecutionCancellation.isPresent()) {
                throw new IllegalStateException("setPeriodicExecutionCancellationCallback has not been called before cancel");
            }

            cancelled = true;
            if (running) return;
        }

        runlet.close();
        periodicExecutionCancellation.get().run();
    }
Cancel the execution of the {@link Runlet}.

<ul>
    <li>Either the runlet will not execute any more {@link Runlet#run()}s, and {@link Runlet#close()}
    and then {@code periodicExecutionCancellation} will be called synchronously, or
    <li>{@link #run()} is executing concurrently by another thread {@code T}. The last call to
    {@link Runlet#run()} will be called by {@code T} shortly, is in progress, or has completed.
    Then {@code T} will call {@link Runlet#close()} followed by {@code periodicExecutionCancellation},
    before the return of {@link #run()}.
</ul>

<p>{@link #setPeriodicExecutionCancellationCallback(Runnable)} must be called happens-before this method.
service-monitor/src/main/java/com/yahoo/vespa/service/executor/CancellableImpl.java