How to trigger after destroy confirmation?

I have a use case where I’d need to run few tasks on a VM while it’s running and before it’s getting destroyed. To achieve this, I added a trigger
MyVM.trigger.before :destroy do |trigger|.

It works, but runs before the destroy confirmation which is a bit bad. Then I started running vagrant destroy --debug to find out what classes it runs so that I could run the trigger after the destroy confirmation.

I added the following

  • to start of the script
    VAGRANT_EXPERIMENTAL=“typed_triggers”

  • under my VM (I would change “before” to “after” when it triggers correctly):
    MyVM.trigger.before :“Vagrant::Action::Builtin::DestroyConfirm”, type: :action do |trigger|
    trigger.info = “Running post tasks INFO”
    trigger.warn = “Running post tasks WARNING”

However, it never triggers

DEBUG config: Trigger defined for: Vagrant::Action::Builtin::DestroyConfirm

DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 0
INFO warden: Calling OUT action: #VagrantPlugins::ProviderVirtualBox::Action::Created:0x000001538179e728
INFO runner: Running action: machine_action_destroy #Vagrant::Action::Warden:0x00000153823647d8
INFO warden: Calling IN action: #<Proc:0x0000015382222258 C:/HashiCorp/Vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/action/warden.rb:126 (lambda)>
INFO warden: Calling IN action: #Vagrant::Action::Builtin::Call:0x00000153823646c0
INFO runner: Running action: machine_action_destroy #Vagrant::Action::Builder:0x0000015382142a90
INFO warden: Calling IN action: #Vagrant::Action::Builtin::DestroyConfirm:0x00000153820660b8
INFO interface: ask: Are you sure you want to destroy the ‘MyVM’ VM? [y/N]
INFO interface: ask: MyVM: Are you sure you want to destroy the ‘MyVM’ VM? [y/N]
MyVM: Are you sure you want to destroy the ‘MyVM’ VM? [y/N]

what could be the issue here?