diff --git a/include/asterisk/calendar.h b/include/asterisk/calendar.h
index a02570bf3226e8a4914bed7a18a2cee8d1769a46..da4af01ef3ded830dc6160655d1dbeab9845a5bb 100644
--- a/include/asterisk/calendar.h
+++ b/include/asterisk/calendar.h
@@ -25,6 +25,7 @@
 #include "asterisk/linkedlists.h"
 #include "asterisk/lock.h"
 #include "asterisk/dial.h"
+#include "asterisk/module.h"
 
 /*! \file calendar.h
  * \brief A general API for managing calendar events with Asterisk
@@ -69,6 +70,7 @@ struct ast_calendar_tech {
 	const char *type;
 	const char *description;
 	const char *module;
+	struct ast_module_user *user;
 	int (* is_busy)(struct ast_calendar *calendar); /*!< Override default busy determination */
 	void *(* load_calendar)(void *data);   /*!< Create private structure, add calendar events, etc. */
 	void *(* unref_calendar)(void *obj);   /*!< Function to be called to free the private structure */
diff --git a/main/loader.c b/main/loader.c
index f9b2de943372b44c33d3103c9d74bd3d9f9885a5..44046ae2a41c0c6dfc7388be7c7169d6437358d8 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -239,7 +239,9 @@ void __ast_module_user_hangup_all(struct ast_module *mod)
 
 	AST_LIST_LOCK(&mod->users);
 	while ((u = AST_LIST_REMOVE_HEAD(&mod->users, entry))) {
-		ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD);
+		if (u->chan) {
+			ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD);
+		}
 		ast_atomic_fetchadd_int(&mod->usecount, -1);
 		ast_free(u);
 	}
diff --git a/res/res_calendar.c b/res/res_calendar.c
index e5a0d929ee73b94de212049b9800358392997c9a..4bcb2639b024b1e076a09d68d992b11e95afa057 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -532,6 +532,7 @@ int ast_calendar_register(struct ast_calendar_tech *tech)
 		}
 	}
 	AST_LIST_INSERT_HEAD(&techs, tech, list);
+	tech->user = ast_module_user_add(NULL);
 	AST_LIST_UNLOCK(&techs);
 
 	ast_verb(2, "Registered calendar type '%s' (%s)\n", tech->type, tech->description);
@@ -564,6 +565,7 @@ void ast_calendar_unregister(struct ast_calendar_tech *tech)
 		ao2_callback(calendars, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, match_caltech_cb, tech);
 
 		AST_LIST_REMOVE_CURRENT(list);
+		ast_module_user_remove(iter->user);
 		ast_verb(2, "Unregistered calendar type '%s'\n", tech->type);
 		break;
 	}