This one is what I use for that. There is actually a single global variable GIsRequestingExit that controls the game loop. So you can just set it to ‘true’ anytime you want and this will initiate the shutdown process.
FGenericPlatformMisc::RequestExit(false);