Hi @lasselauch,
we talked about your problem this morning. There are two ways of looking at your question:
You are interested in the event of a closing document (i.e. present progressive) and you want to react to that event by making some changes before this process is finalized (i.e. the document closed). As already stated yesterday by me, there is currently no way to do that in a GeDialog. You will need some kind of node for that. It is also noteworthy that currently CommandData is bugged in this regard in Python. As
@mp5gosu already pointed out, MessageData is a really good way to go, unless you do not have already something like TagData plugin where you could squeeze in that functionality.
You are interested in the state of the loaded documents list, i.e. if a document has closed (past tense), but not exactly when it happens. This is possible in a dialog. You already provided your own answer here (thanks for making it visible to everyone). The basic idea is just to build some hashmap/list to compare against what Cinema considers to be loaded documents. As an added note, you might want to look at GeDialog.Timer, which will let you execute things in fixed intervals, in order to get closer to the point of when something happened. This won't be to much of a performance strain if implemented carefully.
Cheers,
Ferdinand