docs: public void close(int closemode) {
  
          HsqlException he = null;
  
          setState(DATABASE_CLOSING);
          sessionManager.closeAllSessions();
          sessionManager.clearAll();
  
          if (filesReadOnly) {
              closemode = CLOSEMODE_IMMEDIATELY;
          }
  
          /**
           * @todo  fredt - impact of possible error conditions in closing the log
           * should be investigated for the CLOSEMODE_COMPACT mode
           */
          logger.closeLog(closemode);
  
          try {
              if (closemode == CLOSEMODE_COMPACT) {
                  clearStructures();
                  reopen();
                  setState(DATABASE_CLOSING);
                  logger.closeLog(CLOSEMODE_NORMAL);
              }
          } catch (Throwable t) {
              if (t instanceof HsqlException) {
                  he = (HsqlException) t;
              } else {
                  he = Error.error(ErrorCode.GENERAL_ERROR, t.toString());
              }
          }
  
          logger.releaseLock();
          setState(DATABASE_SHUTDOWN);
          clearStructures();
  
          // fredt - this could change to avoid removing a db from the
          // DatabaseManager repository if there are pending getDatabase()
          // calls
          DatabaseManager.removeDatabase(this);
  
          if (he != null) {
              throw he;
          }
      }