how to stop a loop arduino
Arduino specifically provides absolutely no way to exit their loop function, as exhibited by the code that actually runs it: Besides, on a microcontroller there isn’t anything to exit to in the first place. The closest you can do is to just halt the processor. That will stop processing until it’s reset.