This is how Unicron's defeat goes in One Shall Rise Part 3.
[Unicron possesses Megatron]
Unicron: Megatron, destroy the Prime and Princess. I command you!
[Megatron tries to hold himself back as Unicron forces him towards them]
Megatron: Megatron is commanded by NO ONE!
Princess Celestia: Earthquake!
Ratchet: Take cover!
Optimus Prime: Matrix of Leadership, I call upon you.
Twilight Sparkle: Element of Magic come to me.
[They gain enough power]
Unicron: You cannot defeat me, disciple of Primus and Princess of Friendship. I have transcended physical being. By my will alone, all upon this world shall fall into chaos.
Optimus Prime: Not while we still function, Unicron. The power of the Matrix will light our darkest hour.
Twilight Sparkle: And lead you down the path of Friendship.
[Optimus uses the Matrix and Twilight uses the Element of Magic on Unicron]
[Everything returns to normal]