Just add M99 at end of subroutine
f100 (faster than possible-mach3 will throttle back)
g21 (mm and absolute)
M98 P1 L5 (RUN SUBROUTINE 5 TIMES)
m30 (rewind and stop)
O1 (letter o - this subroutine must be run 5 times)
g01 z-10 (first position)
g01 z1 (do a feedrate move and move back)
M99 (return to main program)