I had the good fortune of having a really awful experience in my first job right out of school. I realize this might not sound like a win, but hear me out.
My first job ended up being a disaster because I worked for someone I’ll call “ethically challenged,” a diplomatic phrase I have since coined with to describe my former boss. Needless to say, this person is not someone on my reference list, and you won’t find the job listed on my LinkedIn profile.
Why was this so lucky? Because it taught me the importance of having a “Walk Away Fund.” This negative experience happened while I had college debt and no savings, which made it very hard to leave and very scary when I did. I frankly couldn’t afford to, and was very fortunate to land a new job almost immediately. I determined then, at age 24, never to allow myself to feel trapped like that again.
I have always been a saver by nature, but this experience motivated me to turn socking it away into a science. I built a budget, created a separate savings account and direct deposited at least 10% of each paycheck into this account. I also put 100% of any annual bonus into the pot. Within a couple of years, I had saved more than enough to have the runway to cover several months of living expenses. With a reasonable cushion established, I felt it was the right time to open an investment account and really start to grow my “Walk Away Fund.”
Savings rates among young women are consistently bleak. A recent study by T. Rowe Price showed that 68% of those not putting any savings into a 401(k) are women. And even when they do save, Millennial women trail their male counterparts: For women ages 18 to 33, the median 401(k) balance is $11,000, but for men in the same age group it’s twice as much: $22,000. Part of this, of course, is due to the fact that women make less overall: The median personal income for Millennial women is $48,000, while men in the same age category earn a median of $63,000, according to the T. Rowe study.
When Life, or the Economy, Goes South
As a woman who is very focused on my career, I never really entertained the idea of marrying, exiting the workforce and becoming financially dependent on someone. But had I taken this path, I am certain I would have maintained this “Walk Away Fund.” Several women I know designated their fund as separate property in a prenuptial agreement—which enabled at least one to move on with her life relatively quickly when her spouse decided to “find himself” after ten years of marriage. While no one enters a marriage planning for a divorce, the stats don’t lie: 40% of young couples marrying for the first time today are expected to divorce at some point. Planning for the unexpected is a smart—and I’d say crucial—move.
Sleep Well at Night
Now that I have a child, I think about my “Walk Away Fund” in a different way. It’s our family’s safety net, in the event that something catastrophic were to happen. While I’ve drawn upon this account over the years for various investments – starting a new business, buying our house when I had a family—I’ve never let it fall low enough that I would be trapped in a job or unable to step away if my family needed me. This flexibility has more soporific qualities than good red wine, and makes me thankful that I was lucky enough to have a real jerk as my first boss.
Ashley Fieglein Johnson joined automated investment service Wealthfront as its chief financial officer in June of this year. Previously, she served as the CFO of ServiceSource (SREV).
Subscribe to The Broadsheet, Fortune’s daily newsletter on the world’s most powerful women.