Hi!
If all your code is inside the while loop, it is normal that when you stop the loop, the program ends.
If you're waiting for an event, you should configure your application to do so, but it's a different kind of programming!
I'm not posting an example because I'd have post an example with 2 while loops, in which the loop inside stops when you click "Stop" button, but the outer loop keep application running... but it's just useless!
Let me know if this helps... have a nice day!
graziano