People criticizing the principals for being stupid should keep in mind that the principals are not real and that this was written by an actual person - an actual person that doesn't happen to be a particularly good writer.
My best guess is they go to look for the black principal and realize he's still in the slime and they got distracted due to the magic and get it to release them.