function ServiceBag.Destroy(Z)local N=getmetatable(ServiceBag)Z._destroying:Fire()local Q=Z._services local B,Y=next(Q)while Y~=nil do Q[B]=nil if not(Z._serviceTypesToInitializeSet and Z._serviceTypesToInitializeSet[B])then task.spawn(function()if Y.Destroy then Y:Destroy()end end)end B,Y=next(Q)end N.Destroy(Z)end return ServiceBag
--[=[
	Cleans up the service bag and all services that have been
	initialized in the service bag.
]=]
function ServiceBag:Destroy()
	local super = getmetatable(ServiceBag)

	self._destroying:Fire()

	local services = self._services
	local key, service = next(services)
	while service ~= nil do
		services[key] = nil

		if not (self._serviceTypesToInitializeSet and self._serviceTypesToInitializeSet[key]) then
			task.spawn(function()
				if service.Destroy then
					service:Destroy()
				end
			end)
		end
		key, service = next(services)
	end

	super.Destroy(self)
end

return ServiceBag
