docs: @SuppressWarnings({ "rawtypes", "unchecked" })
      public Future<Void> close() {
          log.info("Shutting down.");
  
          final Future<Void> closeFuture;
  
          if (this.isClosed.compareAndSet(false, true)) {
              // Since we're (maybe) going to clobber the main event loop group, we should have this promise use the global
              // event executor to notify listeners.
              final Promise<Void> closePromise = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
  
              this.channelPool.close().addListener(new GenericFutureListener<Future<Void>>() {
  
                  @Override
                  public void operationComplete(final Future<Void> closePoolFuture) throws Exception {
                      if (ApnsClient.this.shouldShutDownEventLoopGroup) {
                          ApnsClient.this.eventLoopGroup.shutdownGracefully().addListener(new GenericFutureListener() {
  
                              @Override
                              public void operationComplete(final Future future) throws Exception {
                                  closePromise.trySuccess(null);
                              }
                          });
                      } else {
                          closePromise.trySuccess(null);
                      }
                  }
              });
  
              closeFuture = closePromise;
          } else {
              closeFuture = new SucceededFuture<>(GlobalEventExecutor.INSTANCE, null);
          }
  
          return closeFuture;
      }