function CoreSetup:__end_frame(t, dt)
	self:end_frame(t, dt)
	managers.viewport:end_frame(t, dt)

	if self.__quit then
		if not self:block_quit() then
			CoreEngineAccess._quit()
		end
	elseif self.__exec and not self:block_exec() then
		if managers.network and managers.network:session() then
			managers.network:save()
		end

		if managers.mission then
			managers.mission:destroy()
		end

		if managers.menu_scene then
			managers.menu_scene:pre_unload()
		end
		
		log('Coresetup:__end_frame:World.type='..tostring(type(World))..',value='..tostring(World))
		local status,err=pcall(World.unload_all_units, World)
		if not status then 
			log('coresetup:__end_frame:'..tostring(err))
		end
		--World:unload_all_units()

		if managers.menu_scene then
			managers.menu_scene:unload()
		end

		if managers.blackmarket then
			managers.blackmarket:release_preloaded_blueprints()
		end

		if managers.dyn_resource and not managers.dyn_resource:is_ready_to_close() then
			Application:cleanup_thread_garbage()
			managers.dyn_resource:update()
		end

		if managers.sound_environment then
			managers.sound_environment:destroy()
		end

		TextureCache:abort_all_script_requests()
		self:start_loading_screen()
		managers.dyn_resource:set_file_streaming_chunk_size_mul(0.1, 10)

		if managers.worlddefinition then
			managers.worlddefinition:unload_packages()
		end

		self:unload_packages()
		managers.menu:destroy()
		Overlay:newgui():destroy_all_workspaces()
		Application:cleanup_thread_garbage()
		CoreEngineAccess._exec("core/lib/CoreEntry", self.__context)
	end
end