Something like this?

https://forum.duet3d.com/topic/13194/dsf-extension-exec-on-mcode-was-shutdown-sbc