Well... I suppose, I would look at two things::
1) What is it that makes you so miserable in the residency. I would look at it from two perspectives: how would I explain it to potential employers, as well as how much in terms of lost nerve tissue it is going to cost me.
2) How would not completing this residency affect your long-term career goals.
My approach is, that in order to do something (such as stick with the program) benefits of doing so should clearly outweigh the emotional and/or physical toll it is going to take on you.
Importantly, remember to consider whether this other employment opportunity you are offered will make you miserable as well. I have a friend who keeps accepting offers I don't think she should, and then complains about how miserable this job is making her, switches - and then complains that the new job is even worse than the previous one.