So it was that a duplicitous Chancellor took advantage of this unswerving allegiance. Palpatine, who was in truth Darth Sidious, had masterminded the Clone Wars from its very inception, having arranged the creation of the army through the dead-end front of Sifo-Dyas. As part of a contingency, there were a series of emergency protocols that each clone commander was specifically trained to enact.
[ Clone Troopers ] Order 66 identified the Jedi order as traitors to the Republic that had to be eliminated with all haste and with extreme prejudice. With his shadowy plot fully in motion, Sidious used his wide-spanning communications network to make contact with his loyal clone commanders, and executed Order 66.
The clones turned on their Jedi leaders. They opened fire on the unsuspecting Jedi Knights, bringing to an end Clone War engagements on such varied worlds as Cato Neimoidia, Saleucami, Mygeeto, Felucia, Kashyyyk and Utapau.
With their Jedi leaders taken out, the chain of command placed the clone troopers under the Chancellor, who would regroup and reform his galaxy-spanning armed forces into the stormtrooper ranks that came to symbolize the oppressive might of the Galactic Empire.