A self-destruct mechanism was a defense system that allowed an important craft or device to self-destruct under certain circumstances such as the threat of being captured. This was often used as a last-resort defense to protect data from being used by the enemy.
During the Clone Wars, the Infiltrator demolition droids are both the demolition droids and have the explosion charges which means there are bombers of the Confederacy of Independent Systems set themselves to self-destruct to blow up the central power distribution grid on Coruscant goes the , even to stop the vote for the bill to de-regulate banking conglomerates.
When Han Solo and Chewbacca destroyed a Viper probe droid on Hoth, the droid managed to send relay images of Echo Base before self-destruction. After the Battle of Hoth, every TIE Series starfighter had a self-destruct system installed.
When Rookie One and Ru Murleen destroyed the TIE Phantom factory at Imdaar Alpha they brought the very last TIE Phantom to a Rebel base but the designers had anticipated such a possibility and each fighter was given a self-destruct mechanism disabled by some Imperial code, so that should one fall in the hands of the Rebels, they wouldn't be able to replicate its technology. After the destruction of this short-lived fighter, its technology was lost forever.
The Empire equipped TIE Maulers with a self-destruct mechanism as a means to do additional damage to enemy troops if the TIE Mauler was attacked. The power core of the TIE Mauler would overload and the craft would explode, destroying or damaging troops, vehicles, or structures nearby.
The Zann Consortium were also known to have their Vengeance-class frigates and Aggressor-class Star Destroyers self-destruct by overheating their ship cores should the situation call for it in battle.
Before the New Republic liberated Coruscant from the Galactic Empire, Tycho Celchu volunteered to fly a TIE/LN starfighter to spy on the planet, his starfighter was modified heavily with sensor packages for his mission. He was caught by the Imperials after being hit by two ion-cannon blasts, which disabled the self-destruct system.
As late as 40 ABY, Slave I was equipped with a powerful self-destruct system.