private void leaveGame() {
        int result = JOptionPane.showConfirmDialog(
                this,
                "Are you sure you want to leave a game?",
                "Exit Application",
                JOptionPane.YES_NO_OPTION);
        
        if(result == JOptionPane.YES_OPTION) {
            try {
                while(updater.isAlive()) {
                    updater.stopFlag = true;
                    Thread.sleep(100);
                }
                
                sendToServer(Packet.getLeaveGamePacket());                
                PacketManager.readPacketFromStream(in);                
                
                setContentPane(mainPanel);
            } catch (Exception e) {
                fatalErrorExit("Connection error");
            }
        }
    }