C++ Quit Game

Hello All.

I would think this would be trivial, and given how easy it is to do so in Blueprints, but where is the QuitGame function in C++?

Thank you for the help.

EDIT:
Never mind, I found it: UKismetSystemLibrary::QuitGame | Unreal Engine Documentation

1 Like

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);

6 Likes

Thanks . I’m giving that a try. I like the idea of a clean shutdown. I see that if passed true it is a hasty forced shutdown. . .which could come in handy at times.

Hello there, im having problems with exiting the Game in Standalone Mode.

Normally i used the ConsoleCommand(“exit”) to shutdown and it causes a crash of the engine with an access violation.

The logs print RequestExit(0) as the last logging message

so when i looked inside the FGenericPlatformMisc::RequestExit



void FGenericPlatformMisc::RequestExit( bool Force )
{
	UE_LOG(LogGenericPlatformMisc, Log,  TEXT("FPlatformMisc::RequestExit(%i)"), Force );
	if( Force )
	{
		// Force immediate exit.
		// Dangerous because config code isn't flushed, global destructors aren't called, etc.
		// Suppress abort message and MS reports.
		abort();
	}
	else
	{
		// Tell the platform specific code we want to exit cleanly from the main loop.
		GIsRequestingExit = 1;
	}
}


it seems to be right and i would expect the mainloop to shutdown properly. Does someone has an idea or experiencing the same issue?

best regards

1 Like

I know it’s an old topic, but in case someone has the same problem: You show the code of FGenericPlatformMisc which is most likely not what is being executed. It is more likely to be a RequestExit(bool) method from your specific platform class, for example FWinPlatformMisc::RequestExit(bool). So check the code there.Also keep in mind that abort() signals abnormal termination, which can be seen as a crash, especially if you have a debugger attached - since it is said to simply signal SIGABRT.

OP mentioned they found the solution using UKismetSystemLibrary::QuitGame() anyway.
All that does is PlayerController->ConsoleCommand(“quit”), which is all I’ve ever done :stuck_out_tongue:

2 Likes