If somebody is interested, a workaround is:

In the main window's closeEvent implementation, after calling QMdiArea::closeAllSubWindows() but before testing for QMdiArea::activeSubWindow(), call QMdiArea::activateNextSubWindow(). This seems to do the trick, although I have not tested extensively.

Still, the example application needs to be fixed.