code: public CompletableFuture<Void> deregisterApplicationAndClose(
  			final ApplicationStatus applicationStatus,
  			final @Nullable String diagnostics) {
  
  		if (isRunning.compareAndSet(true, false)) {
  			final CompletableFuture<Void> closeWebMonitorAndDeregisterAppFuture =
  				FutureUtils.composeAfterwards(webMonitorEndpoint.closeAsync(), () -> deregisterApplication(applicationStatus, diagnostics));
  
  			return FutureUtils.composeAfterwards(closeWebMonitorAndDeregisterAppFuture, this::closeAsyncInternal);
  		} else {
  			return terminationFuture;
  		}
  	}
docs: Deregister the Flink application from the resource management system by signalling
  the {@link ResourceManager}.
  
  @param applicationStatus to terminate the application with
  @param diagnostics additional information about the shut down, can be {@code null}
  @return Future which is completed once the shut down