Cancel an event whilst its running

Yess if I change the ‘each with delay’ to ‘completed’ instead of ‘loop body’ it does stop. How would i do that through code on the button press event?