private void closeConnection() {
		logger.finer("Closing connection to server");
		synchronized(CONNECTION_LOCK) {
			if(receivePacketThread != null)
				receivePacketThread.stopReceiving();
			if(timeoutThread != null)
				timeoutThread.stopTimeout();
			if(pingThread != null)
				pingThread.stopPinging();
			if(socket != null)
				socket.close();
			resetVariables();
		}
	}