Your welcome.
M30 should only be used once, at the end of the program. If not used at the end of the program, the program will indeed end, and rewind, ignoring all that comes after it.
It is also better to lay out your programs for a smooth flow. Notice the sub calls are together, the subs are at the tail end, and the rest of the code is back up above the subs with the M30 ending the program. With a quick glance, you can tell that the program consist of a Z move at the beginning, then runs two subs, then makes a couple more moves, then ends (as indicated by the M30). This keeps you from scouring through a big long file, looking for an error(s) when things don't go as expected.