Can I determine inside Ensemble Job that Ensemble tries to shut down the job

Answers

ENSEMBLE may have some signal mechanic.

BUT at Caché level you still have Special Variable $HALT as the last chance handler.
all details https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_vhalt

Most important: 

If you have $HALT set and also have code defined for ^%ZSTOP when a HALT is issued, the $HALT is executed first. $HALT can prevent the termination of the process, if its halt trap routine does not contain a HALT command.   !!!!

Hi Eduard,

I don't think you can do this in onProcessInput but when the corresponding job dies, it will definitely call onTearDown. 

So you can try overriding this method to execute something when Business Service is shut down.

I never tried this, but I think this should work.

Regards,

Sourabh