protected void doOnTerminate(StateEnum state, final C context) {
        if (!context.isTerminated()) {
            try {
                if (isTrace())
                    log.info("terminating context %s", context);

                context.setTerminated();
                handlers.callOnFinalState(state, context);
            } catch (Exception e) {
                log.error("Execution Error in [whenTerminate] handler", e);
            }
        }
    }