This is how our Heroes defeated Kaos in Ryan's Quest.
[Cody is running after that battle]
Cody: Why? It was mine?
??: The heart that is strong and true shall win the Keyblade.
He sees a cloaked figure emerging from the darkness covered in an unearthly glow
Cody: What? You’re saying my heart’s weaker than his?
Cody glares at it in defiance
?????: For that instant, it was.
Cody’s eyes widen and he shakes his head, staring at the floor
?????: However, you can become stronger.
The figure walks closer to him, the X on its chest nearly visible
?????: You showed no fear in stepping through the door to darkness. It held no terror for you. Plunge deeper into the darkness, and your heart will grow even stronger.
Cody: What should I do?
?????: It’s really quite simple. Open yourself to the darkness. That is all. Let your heart, your being become darkness itself
Cody went to see Kaos
Ansem/Cody: So, I see the path has emerged at last.
Kaos: Yes, the Keyhole to the Darkness.
Ansem/Cody: Unlock it and the Heartless will overrun this world.
Kaos: What do I care for that? The Darkness holds no power over me. Rather, I will use it power to rule all world.
Ansem/Cody: Such Confidence.
He summon a Keyblade
Kaos: Wow! Huh? Wait a Minute! This Princesses of hearts are all here. It must be her.
They look at Meg
Ansem/Cody: Without her heart, she will never be able to release her power.
Then they heard the Noise
Kaos: Looks like they are here now. I'll deal with with them myself, stay here til I get back.
Our Heroes saw Kaos
Kaos: I think that you are too late, any moment now the final Keyhole will be unseal and this world will be plunged into Darkness, it is unstoppable.
Ryan: We'll stop it! After coming this far, there's no way we're gonna let that happen!
Kaos: Oh, really? You think you could defeat me? We'll, how about this!
They are fighting him and they defeated him and he went to the Portal, they follow him, Cody appeared
Ansem/Cody: Do you need some help?
Evil Ryan: Is that a-?
Ansem/Cody: Yes. A Keyblade, unlike yours, this Keyblade holds the power to unlock people's heart. Allow me to demonstrate.
He stab Kaos chest
Ansem/Cody: Now, open your heart, surrounded to the Darkness! Become Darkness itself!
Then he vanish and then Kaos is glowing
Kaos: I can feel it. This power is awesome! Darkness! THE REAL DARKNESS!!!!!
[He become a Monster, they are fighting him and they defeated him and then Cody appeared]
Ansem/Cody: How ironic. He was just another puppet after all.
Sci-Ryan: A puppet?
Ansem/Cody: The Heartless were using Kaos from the Beginning. He failed to noticed the darkness in his heart eating away from him. A fitting end for such a fool.