Ideally, never.
The ideal arc of a software engineering career goes something like this:
Freelancing is never going to be able to beat just moving along to the next step in your ideal career arc. Companies offer things like health insurance and income stability. That said, there’s a pragmatism-idealism-insanity-stupidity scale that you personally will be on as you conduct your career.
Idealism is my buddy Steve, who still works in crappy IC roles at startups because that’s what he knows and because he believes that startups are more noble than consulting work. He’s constantly underpaid and overworked, but can’t bring himself to swallow his pride and work for the man.
Where freelancing fits on the scale is squarely in insanity. Insanity is my buddy Frank who never worked a regular job in his life, freelanced from the very beginning, and took ten years before he could start making the same kind of income guys make coming right out of code school. To say nothing of the benefits. Sure, now he hires guys, but it’s not like he’s seeing any additional peace of mind because of it. Now he has the stress of making sure they stay working and managing inevitable conflict. He’s working the same insane schedule he worked since he graduated, only now he has more responsibilities.
What’s stupid? Moving to San Francisco. I’d live Frank’s life and double the workload before I’d work in that wretched hive of scum and villainy.
Once you start falling down the scale from pragmatism, the way you get your life back on the right track is to find the part of the ideal software career arc that you can easily get a job in, and just get back on track. Being on the ideal arc is just so so so much better than not being on the arc that it becomes a thorough no-brainer the longer you stay there.
How do you recognize when you’re falling off? Say you have this great idea for a startup and you’re not sure whether pursuing it is smart or stupid. Well, in this particular case, you have a very easy way to get external validation, apply to YCombinator. If you don’t know what that is, then you’re not playing with a full deck of cards and you need to educate yourself.
You need a real map to success before jumping tracks becomes a viable plan. YCombinator offers just such a map. If you want to start your own business, you need a reliable customer to fund you in the early stages. It can’t be this crazy thing you do before you know whether it’s going to work or not. Because software engineering is a professional career field. You’ve succeeded in life by virtue of being in the club. It’s like trying to further your career as a doctor by starting your own hospital. Insane.