How to interrupt a block while it's running a script, no matter the script?

In my case, I want to make a glide block that can stop gliding before it finishes if a condition is met. I tried putting a “stop this block” inside a custom glide block, but it didn’t work. How can I interrupt certain blocks before they finish running their code?

You can try using a “stop this script” block or a “stop this block”.

but that depends on the way you want to stop the script

Maybe this block can help
DefautProject script pic (1)

I tried both