Hello,
Do not believe this can be done as you want. This works when executed alone:
ThisDatabaseDocument.Close(True)
and this (corrected) by itself:
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:Quit", "", 0, Array())
but not with all the calls and message boxes.
BTW this is not correct:
…LO closes but opens a blank macro window.
Actually LO has crashed & that is a recovery window. It is empty as there is nothing to recover.
You can always create you own menus and enable/disable items.