Cancel motion on safe guard stop

Hi,

When a safe guard stop is triggered the robot program is paused and robot motion is suspended. When safe guard is reactivated, the program resumes as well as robot motion. In our use case we’d like to cancel any pending motion on a safe guard stop. How would one achieve that?
We tried to solve it by writing a register via RTDE from PLC to robot controller on a safe guard stop and evaluate the bit flag in a continuously monitored “if then” block followed by a stop() instruction. However, this still leads to a short motion when safe guard is reset and program execution is resumed. Apparently, the robot program needs some time to pick up the register state and during that time the motion generator is able to resume a bit of the pending motion. Is it possible to avoid that?

Volker