I have a very spotty work record, in and out of work over a period of about 25 years. I started after grad school at age 29, worked full-time about 4.5 years, left and found very little work except part-time and temporary for about 6 years, worked full-time about 3.5 years, left and went back to school, and got another job after a two-year gap with some part-time work. Worked at the last job 3/4 time (my choice) for ten years, and retired at 55 with a small pension. Then I worked very part-time for two years after about a year's gap.
Luckily, my DH had a modest, steady income during that time. I invested a very large chunk of my earnings, close to 100% after taxes near the end.
It is possible to get a good job after being unemployed for a while; it helps if you have a good reason you left the good jobs, and it helps if you have some recent schooling. Recent schoolwork seems to reset the clock. I met my last boss at the school, and volunteered for a few months and got taken on for paid work.
It also helps if you're flexible.