Move the calling of the *_shutdown functions from the signal handler to a new public function, and use that function inside the DBus disconnect handler to make sure resources are cleanly released.
Security type is used all over the place, so move it out to a more common place.