Index: main/dnsmgr.c =================================================================== --- main/dnsmgr.c (revision 375799) +++ main/dnsmgr.c (working copy) @@ -394,12 +394,21 @@ static struct ast_cli_entry cli_refresh = AST_CLI_DEFINE(handle_cli_refresh, "Performs an immediate refresh"); static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the DNS manager status"); +static void dnsmgr_shutdown(void) +{ + ast_cli_unregister(&cli_reload); + ast_cli_unregister(&cli_status); + ast_cli_unregister(&cli_refresh); + ast_sched_context_destroy(sched); +} + int dnsmgr_init(void) { if (!(sched = ast_sched_context_create())) { ast_log(LOG_ERROR, "Unable to create schedule context.\n"); return -1; } + ast_register_atexit(dnsmgr_shutdown); ast_cli_register(&cli_reload); ast_cli_register(&cli_status); ast_cli_register(&cli_refresh);