But never exits. It will exit if I hit enter. I would expect it to exit immediately after printing "program complete".
What is happening here and how can I get the desired behavior?
For technical reasons, stdin is implemented by using an ordinary blocking read on a separate thread, and it is impossible to cancel that read. This can make shutdown of the runtime hang until the user presses enter.
The easy way around is to just exit the process instead of return from main. But keep in mind this won't run destructors for anything that's still alive at that point.
You can also create the runtime manually and shut it down manually, which is good if you want to drop the runtime (eventually) but not end the program.