code: function hide(reason, options) {
          options = options || {};
  
          if (options.closeAll) {
            // We have to make a shallow copy of the array, because otherwise the map will break.
            return $q.all(showingInterims.slice().reverse().map(closeElement));
          } else if (options.closeTo !== undefined) {
            return $q.all(showingInterims.slice(options.closeTo).map(closeElement));
          }
  
          // Hide the latest showing interim element.
          return closeElement(showingInterims[showingInterims.length - 1]);
  
          function closeElement(interim) {
  
            if (!interim) {
              return $q.when(reason);
            }
  
            var hideAction = interim
              .remove(reason, false, options || { })
              .catch(function(reason) { return reason; })
              .finally(function() {
                hidePromises.splice(hidePromises.indexOf(hideAction), 1);
              });
  
            showingInterims.splice(showingInterims.indexOf(interim), 1);
            hidePromises.push(hideAction);
  
            return interim.deferred.promise;
          }
        }
docs: /*
  @ngdoc method
  @name $$interimElement.$service#hide
  @kind function
  
  @description
  Removes the `$interimElement` from the DOM and resolves the promise returned from `show`
  
  @param {*} resolveParam Data to resolve the promise with
  @returns a Promise that will be resolved after the element has been removed.