That was very close! Something very bad nearly happened! (e.g. an accident, or being caught doing something you should be doing). It was so close that it was scary. I was scared (frightened).
The grammar is informal though, because really it should be 'scarily close'.
You might say it to the person driving the car you are in, after another car nearly hits you. Or maybe to your best friend on the phone, after your husband came home and nearly caught you with your lover. Or to a classmate after you pass an exam with the minimum mark.