You can always call std::exit with the desired code.
Unreal doesn't seem to provide an API to set the game's exit code directly, perhaps because not all target platforms can usefully do anything with the exit code and/or not all target platforms should really permit user termination (outside of the OS).
You can confirm this by looking at, say, LaunchWindows.cpp (link requires GitHub access to the Unreal Engine, which is free with registration with Epic) as UE 4.21. You can see that the return value of WinMain is driven by GuardedMain which in turn is driven by FEngineLoop::Init(), which only ever returns the constants 0 or 1. You can reasonably conclude that since
- there is no code during the regular shutdown path handling any sort of user-defined exit code on at least one platform and
- Unreal itself does not call
std::exit and
- Where Unreal calls platform-specific termination calls (like
PostQuitMessage) it always provides a constant to the function, never a user-supplied exit code
that the code doesn't contain an abstraction for handling user-supplied exit codes.