When someone is rescued from a difficult situation by a timely interruption, they are saved by the bell. If you forgot to study for your math test, but there's an unexpected snow day, you've been saved by the bell — you have an extra day to study.
The idiom saved by the bell came from professional boxing. A bell rings to mark the end of each round of fighting. Historically, if a boxer was knocked down and couldn't get up before the referee counted to 10, a "knockout" was declared, and the fighter lost. But if the bell rang before the referee reached 10, the count stopped, and the boxer had the rest period to recover before the next round. He was literally saved by the bell. From this original meaning, the phrase came to refer to any situation where someone is rescued just in time.