How to override Document's shouldCloseWindowController method in Swift

To me, the documentation for this method is not at all clear and needs to provide sample code. I tried searching the dev site for sample projects, but they're no longer where they lived for decades before. And where's the TextEdit sample project?!

I need to override shouldCloseWindowController so I can make sure some sub-windows can be closed before closing the document's one and only window. I've done that, but then have no idea what I'm supposed to do to all the document to close. I tried this, which is what I think the NSDocument version header says to do:

if ((self.windowControllers.first?.shouldCloseDocument) != nil){
	self.canClose(withDelegate:delegate as Any, shouldClose:shouldCloseSelector, contextInfo:contextInfo);
}

But the document never gets the close() method called - only the window goes away.

How to override Document's shouldCloseWindowController method in Swift
 
 
Q