OH MY (;-). You have run into the LOST MACH syndrome . It is where SOMETHING in the XML is corrupt and it make MAch3 do strange things at times.
My suggestion is to backup all your special stuff then wipe out mach3 completely and start over from scratch.
DO you have an original XML that you saved at the beginning of your adventure

NO the saved XMLs from mach won't do as you do not know at what point it started going bad.
ALSO make sure you delete all of the backup xmls (wipe out the directory).
NOW from scratch recreate mach3 AND THEN when everyting is working SAVE a copy of the XML to a safe place OUTSIDE of the mach3 directory. THat way IF it starts again just copy the OLD XML over the NEW XML and off you go again. I had a BATCH file I ran from the DOS prompt that did the whole show in a wink.
That Helps to stabalise Mah3 when you are working in macros and mixed Gcode. Can'rt say why and ART could never find what it was that triggered it.
NOW down to your Probing macro. It will cause problem when you try a While loop with mixed Gcode. The CB and Gcode are runing in seperate threads and get messed up Faster PC have more problems with this than slow PCs ALSO single cores seem better than multi cores . SOMEWHERE someone got the multi threading UNSTABLE.
NOW that is for MachMILL who knows what works in MachTURN.
So what exactly are you trying to do ? Your code is a bit confusing without seeing the whole picture. I assume that you are doing a probing routine in TURN.
(;-) TP