We don't know. For one of our friends the time came when the dog had an apparent liver failure and was then diagnosed as riddled with cancer. Others have told us that the animals will let us know when they don't want to live anymore. There have been times when I thought I heard that plea from my dog. Yet she is still with us and in good spirits five months after the move.
Some owners make the decision when they can no longer handle the needs of their pets.
Old people end up in nursing homes when they become incontinent. Pets are left to the tolerance level of their owners. If we weren't able to be at home during the day, our dog would not live anymore. She needs too much attention with lifting and letting her out at the right times. One friend with a menagerie of two dogs and three cats and vet bills to match tells me, that for her, the time comes only when the animals are hurting and can't be helped.