Bar = NumBars is an unusual way to abort the simulation. Normally you call quit(). ON which manual page have you found this? And can you post your code?