The most important question is, "Has the episode passed the 18-minute mark?"



You can't end the episode too early, or you'll have to fill up the remaining time with other stuff. Thus, a magical solution (or, technically, any solution that seems like it should work) will fail or backfire. (Swarm of the Century, Bats!, etc.)



If enough time has passed, hijinks have been had, and the moral of the day been established, the problem can be solved (with or without magic) satisfyingly, possibly saving the last few minutes for a quick denouement.