Added explicit destroy to the end of the main method for MainWindow to ensure the application quits for packages.