Nick of time.
Nick of time.
Being in the "nick of time" means doing something at the last possible moment, just before it’s too late. The "nick" refers to a small notch or mark, used in past times for tracking points or increments on an item. Doing something in the "nick of time" is akin to hitting the exact mark needed to succeed or avoid disaster.
She arrived in the nick of time.
She arrived just in time to avoid being late.
The firefighters got there in the nick of time to save the house.
The firefighters arrived just in time to save the house.
They completed the project in the nick of time before the deadline.
They finished the project just before the final deadline.