you can use
UKismetSystemLibrary::QuitGame(GetWorld(),UGameplayStatics::GetPlayerController(GetWorld(),0),EQuitPreference::Type::Quit,false);
make sure to #include"Kismet/KismetSystemLibrary.h"
check out unreal docs : UKismetSystemLibrary::QuitGame