The reason for his defeat... was his humanity
If Shigaraki was anymore heartless, he wouldn't have cared that Deku did this right here. He would've just decayed/killed him in the vestige world and then returned to the real world and kept wrecking havoc.
But it didn't happen. Because deep down, Shigaraki was still the same crying boy. Who wanted someone to reach out their hand to help. Deku did that and he lost his hatred. Decay disappeared. And AFO came back before being defeated by Deku for good.
It's hilarious as heinous as Shigaraki was, what caused his defeat was him STILL having humanity, despite claiming to Deku he no longer did. If that was really true, he could've just killed Deku and then everyone else. But it's BECAUSE he was affected by Deku's actions and lost his malice and hatred, than he was even able to be defeated.