InternalWorkingMemory workingMemory = (InternalWorkingMemory) getWorkingMemory();
((EventSupport) getWorkingMemory()).getRuleFlowEventSupport()
.fireBeforeRuleFlowProcessCompleted(this, workingMemory);
// deactivate all node instances of this process instance
while (!nodeInstances.isEmpty()) {
NodeInstance nodeInstance = nodeInstances.get(0);
((org.drools.workflow.instance.NodeInstance) nodeInstance)
.cancel();
}
removeEventListeners();
workingMemory.removeProcessInstance(this);