Though I know it\'ll be a bit silly to ask, still I want to inquire more about the technical perspective of it.
A simple example of an infinite loop:
pub
Your kind of problem looks like a Threading problem. But still, it is now a a good practice to include a stopping flag even in threads