private synchronized void shutdown() {
        if (shutDown) { return; }
        System.out.println("server shutting down.");
        try {
            threadPool.shutdown();
            if (!serverSocket.isClosed()) {
                serverSocket.close();
            }
            Database.getInstance().save();
            shutDown = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }