Years ago right before my little peanut died she must have known the end was near. She was so sick and weak she could hardly walk and would not eat or drink. One day we could not find her in our bedroom where she had been laying for a couple days , so we searched the whole house and somehow even as weak as she was she crawled up a bunch of stairs and was way under a big bed upstairs waiting to die, we found her and rushed her to a animal hospital and she was there for about 3 days in a incubator [sp?] while they did tests to figure what was wrong, but she was getting fluid in her chest cavity and her kidneys were shutting down so there was nothing they could do for her.
I should say that she was given back to me from a vets office in that shape after a surgery because she had some vaginal discharge. She was not her normal self when she went in but still doing ok, the day I got her from that vet she was just limp in my arms all covered in her own waste, the vet told me it was no big deal and she would be fine after the surgery but she only lived about 5 days after she had the "simple" surgery. Even after all these years I still get very upset still talking about that whole mess.
I am sorry to go on about this on your tread, but I would say yes that they know when its time.
Except for my little Tuffy who died a little over 2 weeks ago from FIP, He had a 105.4 temp, his liver and kidneys were shutting down, he had lots of blood in his rectum, and yet that same morning the vet ended his suffering he was still trying to eat and drink and still trying his hardest to be Tuffy, he never gave up on living life right to the very end. He sure lived up to his name.