You don't need to exit it, you just temperately jump out of it
So:
Check to see if push button has been pressed.
If (PB = High and Pin output = low) exit go to routine run function A
else If PB = High and Pin output = HIGH exit go to routine run function B
If no button press contine loop looking for button press.
And the continues looping is already done by loop() ![]()