How to achieve a repeat function that can be stopped

I have the full application running correctly. im just going back through adding in new things i want it to do