tl;dr:
- on Windows a
CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT or CTRL_SHUTDOWN_EVENT is sent as a syscall.SIGTERM to [signal.Notify]
- the code dealing with the SCM might not be triggered when a
syscall.SIGTERM is received
- the shutdown code relies on
defer which does not run when os-Exit is called.
A detailed explanation is found on elastic/elastic-agent#1525. This issue is seen in the Elastic Agent, and part of the problem resides on the elastic-agent-libs