Yeah once Prime learned that Cybertron is Unicron he lead his Autobots in an all out assault. Most Decepticons were killed, but some surrendered. By the time Prime broke through to Megatron's cedilla the war was over. Megatron was left alive so he could witness Prime's victory over Unicron's forces that were quickly taking over the galaxy. Spoiler: Another Decepticon... Starscream was left alive and served Prime until the extradimensional campaign beanie.