There are two options in more complex situations like the one you mention. One is to write asynchronous code. Here's an example:
The statement "rate(200, move)" requests that the "move" function be executed again 1/200th of a second from now, and the browser can make changes to the page during the time between the current execution of "move" and the next.
Another possibility is to have just one loop, not in a function, which does different things depending on a state variable you establish.
The situation in GlowScript VPython is that for simple programs it's possible to write synchronous code despite the fact that one cannot write synchronous programs in JavaScript, which is what VPython compiles to, by the strategem of Streamline rewriting your program to be asynchronous code. This is a big win, especially for nonexpert programmers. But if you want to do certain kinds of complex programming you may have to abandon the synchronous programming scheme.