There isn’t anything implicit to tell your code it’s a destroy - in fact, your code doesn’t really run on destroy since Pulumi is pretty much just deleting the resources. If you need to manage the destroy, you can leverage the automation api sdk (
https://www.pulumi.com/blog/tag/automation-api/) to orchestrate things.