My first cat that I ever had named Stinky left the house right before he died. He was a partial outdoor cat but never left the house for more than a few hours.
Before he died, he took off his collar for the first time and left it in the threshold of my mother's bedroom. He also brought us an over-abundance of "trophies" from outside and was extra affectionate.
We had an old car that was being fixed up (very slowly) in the back part of my property (about 5 acres or more). He climbed into there somehow and died inside. We found him in there a few days after he had gone missing.
I'm not sure why he wanted to leave when he knew he was going to die or even how he knew he was going to die soon. It's sort of a mystery to me.