protected function prepareToExit()
    {
        $this->getSession()->freeze();
        $this->commitFileCache();

        $this->dispatchEvent(new \OxidEsales\EshopCommunity\Internal\ShopEvents\ApplicationExitEvent());

        if ($this->isSearchEngine()) {
            $header = \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Core\Header::class);
            $header->setNonCacheable();
        }

        //Send headers that have been registered
        $header = \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Core\Header::class);
        $header->sendHeader();
    }