The dragon will not be put in a bag because it can survive the fall and the castle falling on it.
And if you needed more than 10 minutes then you were not a proper 5 minute adventuring day adventurer: save the universe once per day in 5 minutes or go back to home.
If you feel too guilty about failing to do all that in 10 minutes then just resurrect the villains you could not save.(and the villains knows that whatever you do to them when resurrecting them is less horrible than their afterlives because they already heard about how you resurrected the people you could not save(commoners and villains included))
If you did not have enough bag of holding throw the villains far away by the windows so that they do not suffer from the castle falling on them after suffering falling damage.
If you have a level 18 wizard set feather fall as a signature spell before crashing in the castle.