No one likes to hear it, but after a certain amount of rejections, sometimes authors have to shelf their manuscripts and move on to writing something different.
The question is, when do you draw the line?
Firs of all, if we're going to sell a manuscript, we have to be smart about it. So don't throw all your eggs (or queries) in one basket, because before you know it you'll be out of agents. What you want to do first is to make sure that you have a finished, polished manuscript (that has preferably seen the eyes of betas) and a nice, polished query (that has, again, been torn apart to perfection.)
The best way to start with querying is query in batches of 5-10. If you're not getting about a 10% request rate, then you should consider revising your query.
What happens if you really, REALLY want to requery an agent because you rewrote your query and you think it's made of sparkily awesomeness? Well, the general rule is, wait at least a month, and make sure that your query is definitely an improvement. Don't kid yourself into thinking changing around a sentence or two is a big change. My rule, is if they reject your second query, stop querying them. They've made their decision, and it probably isn't the query that's not appealing to them.
So, you've gone through your complete list of agents, a few have read it but mostly rejected without any personalization. Do you give up now?
Now, this is a very personal question. Me? I can pump out a novel in a month-2 months. Some take years to write their novel. If I've worked my way through my list, rewrote my query over and over and still got rejected, I would call it quits. Something about my book just won't sell.
But I know many people who continue going. The reason I often don't is by the time I've collected all my rejections, I've realized the problem with the manuscript and why I can't sell it. If I can't fix it, I move on.
But what authors don't seem to understand is that this is such a personal question. There is no number of rejections you get before you throw in your towel. If you find something early on that's really wrong with your manuscript and you can't fix it, move on. If you're really attached to your manuscript and truly believe it will sell, rework you query, let new eyes read it and figure out why it's not selling.
But what I must stress, is if you decide to shelf your manuscript, that doesn't mean you've failed as a writer. It means you still need work. Writing isn't something anyone is just good at. Every writer has to work to be better at their craft. My rule is that if you're shelving your manuscript, you'd better have another one ready to sell. Publishing is all about being stubborn as hell. If you can just keep going and keep getting better, you'll make it some day.