Note that `self.ui:onClose()` properly closes open documents. There might be similar pieces of code around that don't do that. Fixes #4755.