@Override
    public void terminate(final TaskId taskId) {
        securityContext.secure(AppPermission.MANAGE_TASKS_PERMISSION, () -> {
            final TaskContextImpl taskContext = taskRegistry.get(taskId);
            if (taskContext != null) {
                taskContext.terminate();
            }
        });
    }
Tells tasks to terminate and waits for all tasks to terminate before
cleaning up the executors.
stroom-task/stroom-task-impl/src/main/java/stroom/task/impl/TaskManagerImpl.java