private void returnToQueuePreviouslyPeekedEvents() {
    Object[] helpArray = peekedEvents.toArray();
    peekedEvents.clear();
    if (helpArray.length == 0) {
      return;
    }

    for (int i = helpArray.length - 1; i >= 0; i--) {
      GatewaySenderEventImpl event = (GatewaySenderEventImpl) helpArray[i];
      final int bucketId = event.getBucketId();
      BucketRegionQueue brq = getBucketRegionQueueByBucketId(getRandomShadowPR(), bucketId);
      if (brq != null) {
        brq.pushKeyIntoQueue(event.getShadowKey());
      }
    }
  }
This method does the cleanup of any threads, sockets, connection that are held up by the queue.
Note that this cleanup doesn't clean the data held by the queue.
geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java