I am wondering why there is a M2 every time before program end, it means a reset so I am not wondering about the upcoming reset.
Is this processed in Lightburn and could be found in your gcode, correct?
Not familiar with lightburn but I think this could be a setting.
Anyway, I would suggest to set it up like in the lightburn guide or recently there was a official guide published:
https://wiki.snapmaker.com/en/general/manual/use_ray_with_lightburn_guide