This is an interesting situation. I have a skelestruder on my Mk3S and only just printed a set of compatible parts. I started testing purge positions and doing test purges, only to find out my printer resets itself.
The purge made a nice little pellet, but the printer resets when moving away from the purge mechanism... Both with the position testing code (dies on final G1 X100 F12000, sometimes the screen shows 'ERROR: STATIC MEMORY OVERWRITTEN' and the printer bootloops until I reset it) and purge test code (Seems to be the G1 X240 F12000. Screen just goes blank until I reset).
I'll try again with a terminal connected to see if it shows anything interesting... But for now, any ideas what might cause this?
UPDATE: This appears to be a Mk3S firmware bug, unrelated to the gcode.
You may wish to update the "position" and "purge testing" examples on thingiverse in the interim to avoid this happening to other folks. I am running a bleeding-edge firmware though, I cannot say for certain if this is present in the official 3.8.1
The bug appears to happen if a move is in progress when EOF is reached; this can be avoided by making the last line in your file synchronous, e.g. G4 S1 . Side effects can be scary messages and loud beeps/bootloops, though no permanent damage seems to have happened.
I filed a bug with the PR firmware guys ( https://github.com/prusa3d/Prusa-Firmware/issues/2410 )
I've added a "G4 S0.1 ;synchronous command" to the end of the position and purge testing examples on thingiverse.com and prusaprinters.org