How do you know when to give up - on a sick kitty

Such a hard hard hard decision to make. We had a dog, Harley, that required insulin shots twice a day. I did those for him. Also required special diet food from the vet. Money was about $60 for the insulin... $20 for the needles... and the food was $90 a bag. Just about the same amount of time with him after the vet said if he got sick one more time he wouldn't pull through. This year his kidneys started to fail. He also had cataracts. It became a decision on letting him go to sleep before he was miserable and in pain all the time. I still cry over it, but he would have suffered so much more if we hadn't let him go to sleep. And no, I didn't go in with him... couldn't do that. But my niece did and he loved her also.