Your finances: Most industry experts believe that you can afford to leave your job only if you have saved enough money to cover at least six months of expenses as on an average it takes at least six months to find a new job. Further, consider the fact that in most states, unemployment benefits are not offered to people who voluntarily leave their jobs. So, if there isn't much money in the bank, stick it out until you save enough to be able to quit on a whim.
The timing: It doesn't make sense if you quit around the holiday season. During the holidays, most companies offer their employees a lot of paid time off. So, this could be a good time to take up some overtime and save up. Also, hiring managers in a lot of companies are on leave enjoying the holidays; this would slow down your job search. Another time to hold off on your resignation is when the economy is at a downturn. If people are losing jobs all around, you may want to hold on tight to yours. After all, you are one of the lucky ones to still have a job irrespective of how bad it is.
Your job stability: Bear in mind that gaps in a resume are difficult to explain to a prospective employer. In general, hiring managers prefer to extend job offers to people who already have another job as compared to people who are unemployed. So, instead of resigning first and then looking for a job, update your resume and start the job search. As soon as you find a good job, put in your papers. This way you will not have to worry about your finances or come up with explanations for the gaps on your resume.
Salary negotiations: Potential employers usually do not extend offers that pay less than what you take home at your current job. Hence, it pays to have a job when you are negotiating another one. If you are unemployed, there are significant chances of being offered a lower pay you're your last take home as the prospective employer knows that you need the job and will agree to his terms.
Reconciliation: Before you take your final decision, consider whether the problems you are having at work can be resolved or not. Usually, an honest conversation with your manager or an HR representation would do wonders and can turn the situation around. Resolving the issues you have results in a win-win situation for all, and hence, managers do all that they can to ensure that your problems are solved.
However, if you have considered all of the above and have still decided to move on, do it with grace. Give your manager enough notice of your intent to leave so that he can find and train your replacement for the job. Take a proactive role in training the new guy. This will ensure that you leave on good terms and that your manager would not mind giving you a good reference. Also, ensure that you wish everyone, even your sworn enemies at work, well before you leave.