Fixed the finalize application window bug