I agree it's a software issue and not a mechanical one. Some things I would be looking at real close:
Where does the controller think Z 0 is before and after the failure point. Does anything affecting Z height change such as work offset, tool length, machine calibration, or ??? Keep in mind that if it is a programming glitch, options you don't have but the controller can do could also change. I would be going over the g code with a text editor with markup and doing text search for anything that can affect the above.
How big and how many lines are in each file? An example of what can happen in a coding glitch is some times referred to as a buffer over run or variable type mismatch. It happens when a larger number that the programmer intended gets written to a memory location and it's so big it changes the next one after it. Kind of like running out of space on those change of address forms. Those kinds of problems happen at specific numbers base on bit size. Example 8 bit is 256, 16 bit is 65,536.
Good luck, I would also be asking tech support on the controller for help. They should have debug tools that can look for the above problems. Also check for firmware updates and read the change logs.