If you are playing on hardcoe they can die whilst with you, but I'm not sure if they'll also do that when heading back to somewhere. If you're not playing on hardcoe they just go unconsious whilst with you and again I'm not too sure if they will die while heading back to somewhere.
There is an Ingame Mechanism that makes NPCs that are traveling but not in your party get ingnored by ingame enemies. However if you are in the cell with them when enemies approach, these other NPCs may become involved in the battle.
Now, that being said, sometimes the NPCs are still killed by the ingame enemies if you are not around, but that is a glitch. More than likely they get stuck in a pathing issue or a clipping issue if they get lost.
Also, it takes time for the NPCs to return to the home base. Have you tried waiting 72 in game hours?