How to call destroy() on server stopping?

Hi, I have this scenario:

when openfire starts (the user press “start” on openfire console) it has to send a message to an external server saying it is now online, when openfire stops (when user press “stop” on openfire console) it has to send another message saying it is offline.

Problem is that, while init message perfectely works, the destroy() method (which would send the offline message) is not called at all!

Why?How can I solve this problem?