properly break out of the loops when setting final state (closes #6)