code: private void removeContext(final String contextID) {
  
      synchronized (this.contextStack) {
  
        if (!contextID.equals(this.contextStack.peek().getIdentifier())) {
          throw new IllegalStateException("Trying to close context with id `" + contextID +
              "`. But the top context has id `" +
              this.contextStack.peek().getIdentifier() + "`");
        }
  
        this.contextStack.peek().close();
        if (this.contextStack.size() > 1) {
          /* We did not close the root context. Therefore, we need to inform the
           * driver explicitly that this context is closed. The root context notification
           * is implicit in the Evaluator close/done notification.
           */
          this.heartBeatManager.sendHeartbeat(); // Ensure Driver gets notified of context DONE state
        }
        this.contextStack.pop();
        /*
        * At this moment, the Evaluator is actually idle and has some time till the Driver sends it additional work.
        * Also, a potentially large object graph just became orphaned: all the objects instantiated by the context
        * and service injectors can now be garbage collected. So GC call is justified.
        * */
        System.gc();
      }
    }
docs: Remove the context with the given ID from the stack.
  
  @throws IllegalStateException if the given ID does not refer to the top of stack.