Manually delete main window and app objects before termination to avoid segfault on exit