private static void sysExit(SessionState ss, int retCode) {
    try {
      ss.close();
    } catch (IOException e) {
      // If we got an error attempting to ss.close, then it's not likely that
      // ss.err is valid. So we're back to System.err. Also, we don't change
      // the return code, we simply log a warning, and return whatever return
      // code we expected to do already.
      System.err.println(e.getMessage());
      e.printStackTrace(System.err);
    }
    System.exit(retCode);
  }
Wrapper for System.exit that makes sure we close our SessionState
before we exit. This ignores any error generated by attempting to
close the session state, merely printing out the error. The return
code is not changed in such an occurrence because we want to retain
the success code of whatever command we already ran.
hcatalog/core/src/main/java/org/apache/hive/hcatalog/cli/HCatCli.java