Dodged a bullet

Generated image of a man dodging a bullet
The idiom to dodge a bullet means to narrowly avoid something that could have very bad results. It is often used to describe avoiding bad outcome such as a bad relationship, a bad job or a financial loss.

Good thing you didn't buy that stock, it crashed overnight - you dodged a bullet!