Cleanup & destruction
End owned UI lifetimes and disconnect application events deliberately.
Ownership tree#
Window owns Pages, Page owns Sections, and Section owns Controls. Destroying an owner cleans its children, active popups, overlays, subscriptions and animation tasks. Attached windows preserve external Root and Content.
local temporary = section:CreateToggle({Name = "Temporary", Flag = "temporary"})
temporary:Destroy()
local replacement = section:CreateToggle({Name = "Replacement", Flag = "temporary"})
replacement:SetValue(true)
-- On application shutdown:
window:Destroy()
window:Destroy() -- idempotentYour subscriptions#
local connection = game:GetService("Players").PlayerRemoving:Connect(function(player)
print("Player left:", player.Name)
end)
-- This connection belongs to your adapter, not Aroyn:
connection:Disconnect()
window:Destroy()The library cannot clean connections created by your controller. Stop your own loops, disconnect external signals and release references to destroyed handles. Do not call getters or setters after destruction.
Pending work#
Destroy cancels tweens, toast timers and pending AutoSave without a hidden final save. Completed synchronous file calls cannot be undone. Async text measurement that finishes late cannot apply to a destroyed dialog.
Safe reruns#
A stable GUI Id prevents duplicate owned windows. It does not stop gameplay jobs that an application started outside the library. Keep a separate controller cleanup path and invoke it before replacing that runtime.