Just restored the old code, but MyApplication::QuitRequested() will return true every time, with those changes looks like the behaviour is not changing but the crash at program exit is resolved.