Strangely, the last time this happened to one of my games, it was the player of the ranger who left as well.
I had a bit of fun with it (which, I admit, wouldn't necessarily work in all campaigns). I was in the middle of a run with a particular BBEG, and I wanted a Little Bad to challenge the party for a while. In what turned out to be the player's last session (he just stopped coming afterwards), the ranger was knocked unconscious by quickling sleep daggers. The party did a good job of waking everyone else up, but nobody bothered to wake the ranger. Eventually, the quicklings noticed this, and coup-de-graced him (being invisible and all made it hard for the party to notice). The party raised him from the dead, before the end of the session and we ended there for the night.
Unknowing that the player wasn't coming back, I ran him as an NPC for a couple of sessions, but eventually he left, the character stating that he needed to move on (Chaotic Neutral). Off screen, I had my BBEG kidnap the ranger and brainwash him - making him believe that the party hadn't just gotten to him last in the battle with the quicklings, instead having the ranger convinced the party had one out of their way to let him die.
Shortly there after, I had the party ambushed by a mysterious archer. It took a while to discover his identity, and when they found out it was the ranger, there was much paranoia since the ranger had helped them set up most of the traps surrounding their base of operations. He also knew all their weaknesses, so they were less than impressed when he started using arrows of magical beast slaying against the spellcasters' familiars.
Eventually they subdued him (not wanting to kill a former companion) and magically healed the brainwashing. Afterwards, he left for good, needing space away from all the crazyness.