Are you sure it wasn't just a grub? I've never seen a maggot ( fly larvae ) get that big.
If it were me, I would take all that substrate out and use something else. I honestly am not sure if this happens sometimes, as I use newspaper.
Sorry I couldn't be of more help.
Yeah it was probably a grub I just googled the difference, I'm just ignorant when it comes to insects and their larvae forms :\