Pressing the relative item in the Window menu doesn't work as expected. If the selected windows is open, it doesn't close it, while the flag disappear.
Maybe a feature request, not a bug.
Take note that the apple UI guidelines say this is the right behaviour for window menu.
Hold down option key to close.