close call
When something almost happens. Especially something bad, like a collision or social mishap.
Jerry experienced a close call when he was sailing on his boat and a strong gale knocked down his mast and missed his head by a hair.