/*packgage*/ synchronized void onProgramEnd(Outcome outcome) {
// end of the program
// run till the end successfully FIXME: failure comes here, too
// TODO: if program terminates with exception, we need to record it
// TODO: in the error case, we have to close all the open nodes
FlowNode head = new FlowEndNode(this, iotaStr(), (FlowStartNode)startNodes.pop(), result, getCurrentHeads().toArray(new FlowNode[0]));
if (outcome.isFailure())
head.addAction(new ErrorAction(outcome.getAbnormal()));
// shrink everything into a single new head
done = true;
FlowHead first = getFirstHead();
first.setNewHead(head);