How to perform actions before shutdown

Something in my extension is eventually preventing Vassal from closing properly. I would like to close any thread and remove any piece (used to display dice images momentarily) before the player exits.

Is there any “cleanup” method I can use?