public function quit()
    {
        if ($this->connected && $this->socket) {
            $this->executeCommand('QUIT');
            $close = @fclose($this->socket);
            if (!$close) {
                throw new Exception\IOError('Error while closing the connection to the Tor server');
            }
        }

        $this->connected = false;
    }