In the case of a normal application, you will most likely create QApplication and your main window instance on the stack of main(), so they get deleted when main() ends.

In case of it being hidden inside a DLL, you could set the Qt::WA_DeleteOnClose attribute on the window so it gets deleted when it gets closed.
You could also connect the application object's lastWindowClosed() signal to its own deleteLater() slot, or you keep just this object around for further use.

Cheers,
_