I would use a variable. Set the variable to zero at the beginning. Set it to one if the 1 key is pressed. Then, check if the variable is equal to 1 before executing the stack of blocks you want to stop forever.
There might be other ways but this was the first thing that came to my mind.