Actually, especially if you're running it from the Quartus downloader/debugger, there is an "operating system" of sorts. And Altera already told you how it works because they gave you the source code.
The easiest way to see what happens is to run the code in debug mode and look at the disassembly view.
First, see what your 'while(1)' code looks like, then take it out and see where the code eventually winds up. Does it look familiar?
Problem with depending on the _exit() routine to catch you, or lacking that, another 'bsr here' further along in the code, is that it may not be there in a final implementation of your code, running without the debugger, etc.
Also, other environments will not have the same safety net. It is simply a
bad practice to let your code run off the end. Once it does so, you are no longer in control of what happens. Even if you know
exactly what happens today, you do
not know what will happen in version 1.01, 1.02, 1.02b, 2.0, etc.
An idle state might be nice, but if it doesn't exist on this processor, it's useless to try to invent it here. Even so, many processors come
out of idle state on an interrupt and have to loop back to the 'Idle' instruction to re-enter the 'Idle' state. There's the while(1) loop again! Wrapped around the 'Idle' instruction.
Curious is good... spend it on exploring the source code supplied by Altera. Do a text search for 'alt_main' and that will get you close. But leave the while(1) loop in your embedded code regardless of processor, operating system, and the availability (or not) of 'Idle' instructions.
The point is not to see if you can make something unusual work under exactly the right conditions, it is to make it most likely to work under
all conditions. There are enough problems with getting good code to run right, you don't need to stack bad coding on top of that.