Run the main application event loop until stop() is called, and return the exit code passed as argument to stop().