Exit Game Function?

virtual void BeginDestroy() override;

void AMyGameMode::BeginDestroy()
{
	Super::BeginDestroy();
	
	...
	your logic code...
	...
}