From CNC.xyz Wiki
The Program End M-command code known as M02 is commonly found at the end of every G-Code program. The command signals the CNC Control Software to shut down and reset for the next program or set of instructions.
Upon calling a program end code, the spindle stop code M05 and coolant stop code M09 will also typically be executed simultaneously.
Standard Format: M02