code: private JsonWriter close(JsonScope empty, JsonScope nonempty, String closeBracket)
        throws IOException {
      JsonScope context = peek();
      if (context != nonempty && context != empty) {
        throw new IllegalStateException("Nesting problem: " + stack);
      }
      if (deferredName != null) {
        throw new IllegalStateException("Dangling name: " + deferredName);
      }
  
      stack.remove(stack.size() - 1);
      if (context == nonempty) {
        newline();
      }
      out.write(closeBracket);
      return this;
    }
docs: Closes the current scope by appending any necessary whitespace and the
  given bracket.