I have a script that I want to stop a function if a certain event happens, but I don't know how to stop a function while it's running. How do I do it?