how to create a before shutdown trigger