Is it after a certain time?
If it's happened to you already what was the threshold?
The market comes and goes and so does your personal value in a long career. I’ve had job hunts that lasted a year, I’ve had some that lasted one day.
For me, "giving up" would be less about leaving tech and more about re-prioritizing towards other passions.
Best of luck!
At some point, you are going to fail the age test at FAANG+, with emphasis on the "A". I interviewed at one startup and absolutely aced the interview and "exam". They hired a couple of kids, so when the systems crashed on a weekend, they were partying in Tahoe, but you know what? Nobody cared. They were bought out by a two-letter company. I aced a LOT of interviews, to no avail.
OK, you're then into consulting gigs with really small startups who have no "HR" department, so they goof and actually hire qualified people. But at that point, it really 100% depends on your networking (It may be so for all jobs these days with AI-driven recruiters and AI-driven applicants (out of necessity, if not by choice)).
Build and maintain a large and strong network, and at some point, that might get you past the "gray hair recognition" system.
What I find so interesting in posts like this, is the mindset that "someone has to give me a job, else I can't work in IT".
By contrast, when I started, there were jobs sure, but the whole IT industry was so new that most people just found ways to "add value". Our (future) customers didn't know what they needed, we just built it for them.
Today we'd call this a 'startup' (although we were bootstraped, no investment. ) There's still a strong "build it" approach to IT , but mostly it now attracts those "looking for a job".
With hindsight I get that most people (in all industries) are workers, not creators. I used to think IT was mostly creators, but I'm not sure that was ever true. (More likely just the circles I frequented.)
And yes, it's harder to be a creator now. Marketing matters more than coding (it always has) but there is more competition now.
So to answer your question, the time to quit is when you can't add value. If you can see past the "get job" part, and see the "add value" part, your options are still open.
So my advice is; help people. Spot the pain, ease the pain. Maybe it's helping folk at a nearby old-age-community with their cell phones. Maybe it's helping a local corner shop get on the web. Maybe it's simplifying a tedious process.
By helping real people you get to meet more people. And ultimately it's people that get you hired.
Good luck.