Saved by the bell

Generated image of someone being saved by the bell
You are saved by the bell if you are saved from a difficult situation at the last minute.
There are a few theories how the idiom came about. One is that it refers to a school bell or a competition bell that signals the end of class or the current competition.
The more interesting, but possibly less accurate theory is that it came from people's fear of being buried alive in a cemetery, and people were buried with a string tied to their finger and then to a bell above ground, and ringing the bell meant people would come save you.

She forgot to prepare for the presentation, but a fire drill was called and she was saved by the bell