You should examine the file o.g which implements the important parts of the simulation setup and control. Note where barriers are placed. When running, node 0 waits at barrier 8 while you interact with the simulation through the control panel. Meanwhile the other nodes are waiting at barrier 7 for commands. When you press the quit button, node 0 completes barrier 7, and which allows the other nodes to enter barrier 8 and thus complete it.
All nodes then execute paroff and quit and the simulation is over.
The control structure here is an example of how barriers can be used to coordinate the actions of multiple processes. The actual work of stepping the simulation is handled by the function autosweep in this file. You should understand that ALL the nodes execute the demo.g script and included scripts.