code: function (exiting, exitQueue, onExit) {
            var exitingNames = {};
            angular.forEach(exitQueue, function (state) {
              exitingNames[state.self.name] = true;
            });
  
            angular.forEach(inactiveStates, function (inactiveExiting, name) {
              // TODO: Might need to run the inactivations in the proper depth-first order?
              if (!exitingNames[name] && inactiveExiting.includes[exiting.name]) {
                if (DEBUG) $log.debug("Exiting " + name + " because it's a substate of " + exiting.name + " and wasn't found in ", exitingNames);
                if (inactiveExiting.self.onExit)
                  $injector.invoke(inactiveExiting.self.onExit, inactiveExiting.self, inactiveExiting.locals.globals);
                angular.forEach(inactiveExiting.locals, function(localval, key) {
                  delete inactivePseudoState.locals[key];
                });
                inactiveExiting.locals = null;
                inactiveExiting.self.status = 'exited';
                delete inactiveStates[name];
              }
            });
  
            if (onExit)
              $injector.invoke(onExit, exiting.self, exiting.locals.globals);
            exiting.locals = null;
            exiting.self.status = 'exited';
            delete inactiveStates[exiting.self.name];
          }
docs: Exits all inactivated descendant substates when the ancestor state is exited. When transitionTo is exiting a state, this function is called with the state being exited.  It checks the registry of inactivated states for descendants of the exited state and also exits those descendants.  It then removes the locals and de-registers the state from the inactivated registry.