The lifetime of the inner event loop loop
is the existence of MainWindow, which is essentially the lifetime of the application. What if you put your inner loop in some object that you can make go away, for example a button that gets created and then destroyed? Then I bet you would see that that inner loop stops handling events and the main loop does again.