When I do get to that point I usually stop my coding work for the day. I will spend the rest of my time doing research, catching up on small non programming tasks, or even take a small walk to get some fresh air. But what's important is for me to clear my mind so I will be ready for the next day of programming.
Another key to coping with a programming job is to get a good nights rest and stay healthy. There is nothing worse than sleeping only 4 hours then go to work and create a complex algorithm. Not having enough sleep will hinder your productivity and cause you to make careless mistakes that you will have to debug in the future.
You will also find that if you don't exercise or eat right then the sedentary life style will cause your body to become tired and less focused. As for me, I usually work out a few times a week, I take a scooter to work, and I try to get my daily dosage of fruits and veggies. A combination of bad health, sleep deprivation, and a stressful job will guarantee you an early grave. The Japanese likes to call this Karoshi, which means working to death.
Although this next advice is dictated by your company policy, you have to remember to take at least 2 to 3 weeks of vacation a year, and never try to do overtime. When you take your vacation, don't take them in small chunks, but take them in one long chunk. Your mind needs to recharge its batteries, and studies show that you will come back to work more productive.
You also give your coworkers a chance to realize what kind of contributions you make to the company. Also doing more than 8 hours of work in a day will cause you to produce code that is riddled with bugs because your mind is cluttered. Always keep your mind clear when tackling complex problems. You must make sure you voice your opinions and make your case to your employer, or it might be time to find another job that will allow you to have that much needed work/life balance.
I have no idea how stressful other careers are, but I do know how stressful my job can be. 75% of the work I do is not considered to be very stressful, but there is still that 25% where I wish I could just disappear from civilization and start a new life as a Munk. Early on, when I was just starting to study Computer Science, I realized that I needed to pace myself if I was going to graduate. In school it was easy to pace myself because I was my own boss, and managed my own time. I graduated with a decent grade, which is not easy to do in Informatics. I had a better grade than my friend who was a graphic artist, and accomplished this while working up to 2 part-time jobs, which almost equaled one full-time job.
Once I entered the workforce I was very overwhelmed, because I've always coded at my own pace, never doing more than a few hours a day. But how was I suppose to fill up an 8 hour day packed with back to back programming? I almost lost my mind trying to sit in front of a monitor for 8 straight hours, coding myself to death. I learned from that experience, and promised myself that my own health is more important than any job.
So now I don't do more programming than I can handle, and if there is a deadline I definitely let my employer know what I can and can't do. I plan on being a programmer for many more years, and I don't want to go Karoshi. I'm not a coding samurai, I'm a Korean Mountain Man, I work to live not live to work.
I hope you find these tips helpfule, and if you are a programmer, what does your work week look like?