The function
current-process-in-cleanup-p
returns true after the current process is killed. In particular, it returns true while the cleanups that were set by ensure-process-cleanup execute.
LispWorks User Guide and Reference Manual - 21 Dec 2011