See Brainstorming: Long Running Macros and Urgent Commands (Live Adjust Z / CANCEL_PRINT) for some background and associated information (in particular the link to New gcode to interrupt the pending command queue).
1 Like