[dedicated server]how to give server a notice when shutdown server?

I build Standalone Dedicated Server in shipping mode, when I start server program in CMD: MyServer.exe -log, server started successfully and my client can connect to, but it run in backstage, my question is how can I shutdown MyServer.exe normally? in my server, there are some logic(e.g. write player’s data from memory to database) need to be done when server exit, if I kill process MyServer.exe immediately, the data of players would rollback.

I write some logic in AMyGameMode::BeginDestroy() which override from AActor::BeginDestroy(), this function would be called when server started in UE4 Editor and click Stop button

this pic shows the process that run in backstage, is there a safe way to exit process

I got idea from forums: use a special client which allow to send CloseServer message only to server, then invoke QuitGame function on server-side:

#include "KismetSystemLibrary.h"

void ASomeActor::SomeActorFunction()
{
	UKismetSystemLibrary::QuitGame(this, nullptr, EQuitPreference::Quit);
}

hi i put it in my gameinstance but does not work.

It’s works well in my app, I call it in the Event of UMG Button OnClick.

Where did you find the information to make the “special client”?

In my app, I use TCP to send message to server.

Hi, i got the same question as you, and i don’t konw how to solve it. Have you solved the problem? Can you share the solution, thank you very much!