Just a note that you can call the quit slot before a.exec(), but it will not have any effect since the event loop is not running.
Either call quit() after a.exec(), as in create objects that you instantiate in your main function and that use the event loop.
Or use a timer, but then you don't really need the event loop in the first place I guess.