Location of gcode executing before and after my gcode file
I am using Repetier-Server with a Lowrider2 CNC machine. When I run a gcode file, I have noticed several gcode commands are executing prior my file. I noticed because the firmware is saying they don't exist. Then when the file is complete, the CNC moves to the Max Y, Min Z and resets the X and Z position values. And if Stop is selected it does the same thing, but the Z axis is not raised and a trench is dug across the stock until I can hit the Emergency Stop icon. It would be nice if Stop just stopped movement and did nothing else. And Pause did the same thing, but would let you resume. Maybe Pause does do that, but I thought I hit it first, it started moving, then I hit Stop, kept moving, then hit Emergency Stop icon/Full Stop, but it was already 3/4 diagonally across the piece.
I would like to customize the gcode, so at the end of a job, it would raise the Z axis to a safe height and move to the origin. If I hit Pause, it just stops where it is, and Stop - either the same, or raise the Z axis and return to origin. Where and how can that code be changed. Thank you.