function cancel(reason, options) {
        var interim = showingInterims.pop();
        if (!interim) {
          return $q.when(reason);
        }

        var cancelAction = interim
          .remove(reason, true, options || {})
          .catch(function(reason) { return reason; })
          .finally(function() {
            hidePromises.splice(hidePromises.indexOf(cancelAction), 1);
          });

        hidePromises.push(cancelAction);

        // Since AngularJS 1.6.7, promises will be logged to $exceptionHandler when the promise
        // is not handling the rejection. We create a pseudo catch handler, which will prevent the
        // promise from being logged to the $exceptionHandler.
        return interim.deferred.promise.catch(angular.noop);
      }
@ngdoc method
@name $$interimElementProvider.$service#cancel
@kind function

@description
Removes the `$interimElement` from the DOM and rejects the Promise returned from `show()`.

@param {*} reason Data used to resolve the Promise
@param {object} options map of options and values
@returns {Promise} Promise that will be resolved after the element has been removed
 from the DOM.