Can't close docked panels from the Window>Panels menu

All of my panels are docked on the right side. If I go to Window>Panels, the dropdown list has checkmarks next to the panels which are currently shown. If I click on one of those, I expect it to uncheck and hide the panel. It doesn’t. All it does is bring the panel to the front.

If a panel is undocked, then it works as expected, the panel is closed.

In my first test I tried with the Layers panel.
‘Of course’ that worked as expected…

…but Layers seems to be the only one.