A stop codon is a nucleotide triplet within mRNA that signals the termination of protein synthesis during translation. It plays a crucial role in ensuring that proteins are synthesized to their correct lengths by indicating to the ribosome when to stop adding amino acids to the growing polypeptide chain. There are three specific stop codons: UAA, UAG, and UGA, which do not correspond to any amino acid and instead trigger the release of the newly formed protein from the ribosome.