// and have no outgoing transitions: end the process instance here
if(activity.getParent() == activity.getProcessDefinition()
&& activity.getOutgoingTransitions().isEmpty()) {
parentScopeExecution.setActivity(activity);
// we call end() because it sets isEnded on the execution
parentScopeExecution.performOperation(PROCESS_END);
} else {
parentScopeExecution.setActivity(parentActivity);
parentScopeExecution.performOperation(ACTIVITY_NOTIFY_LISTENER_END);
}
}