My "cancel.g", run by the printer when a print is canceled (after a pause).

[[language]]
; stop.g
; called when a print is cancelled after a pause.
G10 P0 S0 ; Turn off the effector heater
M106 P2 S0 ; Turn off Fan 2\. It cools the drivers. We'll turn it on only while printing. DE 2018 01 28
G28 ; Home. DE 2018 02 01

Note: You probably do NOT want home (G28) in either one of these on a cartesian.