Actually I think that closing events aren't the kind of events you can mess with. You can certainly be notified but you cannot prevent its execution (unless I am wrong). So the scenario you are talking about is no surprise.
So depending of what you want to achieve, you may need to change your strategy.
Thanks - our extension is a kind of connection to another system. Before closing the document I'm sending previews of the document to our system and the user can 'check in' the document, he can select a workflow status etc. And I'm writing some informations as labels in the document.
So I like to show a dialog for the user, this dialog get's informations from our system using asynchronous communication and the asynchronous communication doesn't work with a modal dialog.
I can retrieve most of the informations I like to display in the dialog before opening it. But after closing the dialog I like to write the labels into the document and at this time it's already closed.
I think I'll find another way with a different strategy..
Well in this case add a second eventlistener > afterClose. Everytime a doc is closed, use beforeClose to store doc path.
then on afterClose run dialog, reopen doc with no window and generate previews.
you might want to disable listeners during this phase so it doesn’t fire unnecessary callbacks.
eventually turn them on again.