@Tobias – hm, would it help to deactivate/activate the Notes Panel?
It's just a plain panel, that you can get by its name and set visibility to true or false.
Did not try that yet with your code.
For a German InDesign that would be:
app.panels.itemByName("Notizen").visible = false;
For all versions of InDesign we first have to look for an appropriate string.
In my German InDesign I am searching with:
app.findKeyStrings("Notizen");
which gives me an array with two entrys:
$ID/#AppBarNotes, $ID/Notes
So the following should work in all InDesign versions:
app.panels.itemByName("$ID/Notes").visible = false;
Uwe