The program does not need to call SetConsoleCtrlHandler() if the only concern is shutdown via DllMain. The default action of GenerateConsoleCtrlEvent() is to call ExitProcess() which calls DllMain with DLL_PROCESS_DETACH, however it does not get called with DLL_THREAD_DETACH.
The idea way would be to have a thread of the server waiting on an Event, then fire the Event when closedown is needed.