private static void stopAgentIfKilled(AgentManager agentManager) {
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            try {
                LOGGER.info("stopping agent gracefully");
                agentManager.stop();
                AuditUtils.send();
            } catch (Exception ex) {
                LOGGER.error("stop agent manager error: ", ex);
            }
        }));
    }
Stopping agent manager gracefully if it was killed.

@param agentManager agent manager
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentMain.java