code: public void shutdown() throws Exception {
      if (shutdown.getAndSet(true)) {
        throw new IllegalStateException("Cannot shut down a publisher already shut-down.");
      }
      if (currentAlarmFuture != null && activeAlarm.getAndSet(false)) {
        currentAlarmFuture.cancel(false);
      }
      publishAllOutstanding();
      backgroundResources.shutdown();
    }
docs: Schedules immediate publishing of any outstanding messages and waits until all are processed.
  
  <p>Sends remaining outstanding messages and prevents future calls to publish. This method
  should be invoked prior to deleting the {@link Publisher} object in order to ensure that no
  pending messages are lost.