code: public Queue<T> close() {
          CompletableFuture<Queue<T>> pending = null;
          Queue<T> result = null;
          synchronized (this.contents) {
              if (!this.closed) {
                  this.closed = true;
                  pending = this.pendingTake;
                  this.pendingTake = null;
                  result = fetch(this.contents.size());
              }
          }
  
          // Cancel any pending poll request.
          if (pending != null) {
              pending.cancel(true);
          }
  
          return result != null ? result : new LinkedList<>();
      }
docs: Closes the queue and prevents any other access to it. Any blocked call to takeAllItems() will fail with InterruptedException.
  
  @return If the queue has any more items in it, these will be returned here in the order in which they were inserted.
  The items are guaranteed not to be returned both here and via take()/poll().