why, what do you want to achieve; there are already such hooks The original request was sorry for the noise : is there in mkiv a very last macro ? I mean something like \IamCallAtTheReallyEnd{..} which does absolutly nothing to the pdf , and after which mkiv ends without calls any other macro
Peter suggest to use \everylastshipout; but this \def\LuigisWhateverShouldHappen{\immediate\write16{BOOOM!}Something Luigi want to do for some unknown reason.\immediate\write16{BOOOM!}} \appendtoks\LuigisWhateverShouldHappen \to \everylastshipout \starttext hello \stoptext write Something Luigi want to do for some unknown reason. near the bottom of pdf (and I don't want it) and BOOM! on log (which is a way to say that this macro was called) Aditya suggests to put nothing to print in \LuigisWhateverShouldHappen and I said that it's no a robust solution . BTW, for a specific document, this is actually a solution -- just need a bit of test -- I'm almost sure that there is no solutions much differents from this one.
From luatex.web , around line 22423 :
@ We don't want to leave |main_control| immediately when a |stop| command is sensed, because it may be necessary to invoke an \.{\\output} routine several times before things really grind to a halt. (The output routine might even say `\.{\\gdef\\end\{...\}}', to prolong the life of the job.) Therefore |its_all_over| is |true| only when the current page and contribution list are empty, and when the last output was not a ``dead cycle.'' -- luigi