Please find attached an old (needs love) patch to write messages to stderr on exit. Perhaps it can be of use.