This in isolation doesn't appear to make much sense, but to provide an answer to your very question, you can connect with Qt::QueuedConnection and then the quit call will be received when running the event loop and then the loop will quit correctly.
This works because slots are executed in order of the connect calls, so another slot that too happens to be connected to sig() can do whatever it wants, even start an own event loop. However, the last connection is yours, and its queued call to quit will happen last with no other event loop action in between the queued call to quit and the call to loop.exec.
Remember that local QEventLoops, just like calls to QApplication::processEvents, are very dangerous. If you can change the code, try to setup a statemachine to do asynchronous work.