It looks like you modified my M889 macro? By chance are you in G91 mode when it crashes. The default M889 macro has code to prevent it from crashing into the switch, provided you home the Z axis first. Not sure how much of the original macro you're using, if any?
It's also possible that the G100 doesn't support G31 properly. If that's the case, you may not be able to get any macro to work.