The self-destruct sequence is a security system that lets a starship's senior officers destroy their own vessel rather than allow it to fall into enemy hands.
Activating the sequence requires voice authorization from several senior officers, each giving a personal code, followed by a countdown. The captain can cancel it with another authorization until the final moments.
Captain Kirk used the sequence to destroy the original Enterprise above the Genesis Planet after a Klingon boarding party sent by Kruge tried to seize the ship. Kirk, Montgomery Scott and Pavel Chekov entered their codes, and the explosion killed most of the boarders while Kirk's crew beamed down to the planet.