This is my end gcode for shutting everything down-

M104 S0 ; turn off extruder
M140 S0 ; turn off bed
M84 ; disable motors