The DataStore in ModuleScript does not save player data

My DataStore doesn’t save player data for some reason. I tried to transfer myData:UpdateAsync() from ModuleScript to the ServerScript, but it still didn’t work.

1) The compiler does not output any errors
2) Saving works sometimes
3) The changed data is also not saved!

I also searched for a similar problem on the forum, but I never found the solution I needed. I will be very grateful to any of your advice!

Module Script

local ds = game:GetService("DataStoreService")
local myData = ds:GetDataStore("MyData")

function data.Load(plr)
	local success, getData = pcall(myData.GetAsync, myData, plr.UserId.."-Data")
	...
end

function data.Save(plr)
	local toSave = {}
	
	for folderName, array in dataConstructor do
        ... -- Fill "toSave" dictionary
	end
	
	local success, msg = pcall(myData.UpdateAsync, myData, plr.UserId.."-Data", function()
		return toSave
	end)
end

Server Script

local ds = game:GetService("DataStoreService")
local myData = ds:GetDataStore("MyData")
local dataModule = require(game.ServerScriptService.DataModule)

game.Players.PlayerAdded:Connect(function(plr)
	dataModule.Load(plr)
end)

game.Players.PlayerRemoving:Connect(function(plr)
	dataModule.Save(plr)
end)

game:BindToClose(function()
	if #game.Players:GetPlayers() <= 1 then return end
	for _, plr in ipairs(game.Players:GetPlayers()) do
		coroutine.wrap(dataModule.Save(plr))
	end
end)

Saved / Loaded data

-- data = myData:GetAsync(...)
local data = {
 ["Effects"] = {},
      ["Equipments"] =  ▶ {CurrentEffect = "Fire", CurrentAbility = ""},
      ["InventorySettings"] =  ▶ {...},
      ["Others"] =  ▶ {...},
      ["Pets"] =  ▶ {["Red Dragon"] = {Multi = 15, Class = "Normal"}},
      ["Values"] =  ▶ {...}
}

I was able to find a solution to this problem:

game:BindToClose(function()
    if RunService:IsStudio() then task.wait(2) end
    -- Delay for saving Data in the Roblox Studio
    -- because the server in the studio is closing too fast
end)