public function close()
    {
        if ($this->opened) {
            if ($this->shouldRegenerateId()) {
                $this->regenerateId();
            }

            $this->updateLastTrace();
            $this->save();

            $this->values = array();
            $this->opened = false;
        }
    }