add before destroy callback in template

Stupid technique to overcome the issue
https://github.com/mongoid/mongoid/issues/3165