Plugin Widget not closing

So I was just messing around with plugin to get a bit familiar with it, and I managed to do something which I don’t understand how.

-- Create a new toolbar section titled "Custom Script Tools"
local toolbar = plugin:CreateToolbar("Toolbar")

-- Add a toolbar button named "Create Empty Script"
local Button = toolbar:CreateButton("Button", "just a test button","rbxassetid://2778270261")
-- Make button clickable even if 3D viewport is hidden
Button.ClickableWhenViewportHidden = true


-- Create new 'DockWidgetPluginGuiInfo' object
local widgetInfo = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Float,  -- Widget will be initialized in floating panel
	true,   -- Widget will be initially enabled
	false,  -- Don't override the previous enabled state
	200,    -- Default width of the floating window
	300,    -- Default height of the floating window
	150,    -- Minimum width of the floating window (optional)
	150     -- Minimum height of the floating window (optional)
)

-- Create new widget GUI
local testWidget = plugin:CreateDockWidgetPluginGui("TestWidget", widgetInfo)
testWidget.Title = "widget"

local testButton = Instance.new("TextButton")
testButton.BorderSizePixel = 0
testButton.TextSize = 20
testButton.TextColor3 = Color3.new(1,0.2,0.4)
testButton.AnchorPoint = Vector2.new(0.5,0.5)
testButton.Size = UDim2.new(1,0,1,0)
testButton.Position = UDim2.new(0.5,0,0.5,0)
testButton.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton.Text = "Click Me"
testButton.Parent = testWidget

Button.Click:Connect(function()
	testWidget.Enabled = true
end)

testWidget:BindToClose(function()
	TodoListButton:SetActive(false)
end)

The Widget won’t close, no joke. I have no idea how I did that. Is it a loophole, a bug, or what? Please assist.

See PluginGui:BindToClose. Default widget closing behaviour is overwritten if you use BindToClose at minimum one time, so you as the developer are responsible for closing the widget by setting Enabled to false when your own logic finishes. This allows for the widget to stay open in case you have something like a save confirmation prompt for an editing plugin.

It’s a case of not reading documentation, not a bug or anything else.

Oh thank you so much for your reply Mr. Colbert!!