If you are really unhappy in a PhD position, there is no way that you should continue to make yourself miserable for n number of years. However, a failed PhD is not good for anyone's CV and if you possibly can, you should stick at it. After all, you can move on to a related topic that interests you more as a Post-doc.