Have you seen this page, they are wiring up application events within an addin.
In the past I've set the onDemand property to False for a button which forces the addin button to load and you can run code in the onstartup() but this does not deal with shutdown.