There might be a safety issue here, in that keeping the spindle running until it moves to the safe place might prevent the bit from snapping (or worse, damaging the milling motor) if it were to hit the stock.
This is my pause.g file (it includes triggering a LED to show it's in Pause mode and a method of storing the spindle speed on resume*):
; pause.g
M42 P8 S0 ; pause/resume LED off
set global.PausePress = !global.PausePress ; toggle the value from whatever it was before
set global.savedSpindleSpeed = spindles[0].active ; sets the global variable
echo "Spindle speed saved at ", {global.savedSpindleSpeed}, "RPM" ; shows saved spindle speed in the Console
G1 Z{max(move.axes[2].userPosition+5,move.axes[2].max-5)} F2400 ; move the Z axis to a safe height
G0 X273.5 Y560 ; move XY to a safe place
M5 ; turn the spindle off
...and the respective resume.g (with a bit of tool confirmation, but some of this might be spurious - but it works!) but note the indents are critical:
; resume.g
M42 P8 S1 ; pause/resume LED off
set global.PausePress = !global.PausePress ; toggle the value from whatever it was before
if state.currentTool =-1
echo "No tool active. Selecting tool zero"
T0 ; select tool zero
if state.currentTool >= 0
echo "Spindle state on tool ", state.currentTool, " is ", spindles[state.currentTool].state
if {state.currentTool >= 0} & {tools[state.currentTool].spindleRpm >= 0}
M3 S{global.savedSpindleSpeed} ; resume saved spindle speed
G4 S1 ; wait 1 second to allow the spindle to spin up
echo "Spindle speed resumed at " ^ {global.savedSpindleSpeed} ^ "RPM" ; this should show that the setting was successful
G0 R1 X0 Y0 ; move X and Y back to saved work XY location
G1 R1 Z0 F240 ; move Z slowly down to saved work Z location
*I'm happy to provide the configuration lines from the config.g, stop.g and trigger2.g files, if you want to incorporate those features, too?