The rule of thumb I've always heard is that when the bad days outnumber the good, it's probably time to let him peacefully go. Until then, give him as much love and help him be as comfortable as possible.
And stay with him when it's time. I'd hate to think that my dog's last sight before passing on is me leaving the room.