Well you need to figure out what is killing you and ensure your not vunerable to it whilst you are away from your keyboard…
Is it food / hunger : then you need to time how long you can be standing still and not eat/drink before it gets to a dangerous point and ensure you are not absent longer than that. Also ensure you have full meters before you go away.
Is it from sandstorm damage even though you leave your character inside an area that says it’s full shelter … well easiest solution if you can make a sandstorm mask is to put that on before you go away from your keyboard. If you can’t yet make a protective mask then you need to find a guaranteed protected place inside your building … unfortunately the game is glitched and some full shelter areas inside a base actually don’t give you protection… but you can figure that out and avoid leaving your character there.
If you are dying from temperature affects … Eg frostbite or heat stroke because you are in one of the extreme temperature zones that require not ONLY the appropriate armour to survive but ALSO constant consumption of warming or cooling food/drink … well then quite frankly you can NOT go away from your keyboard for longer than that warming/cooling effect lasts … you will need to get to a different area before you go away from the game or log out.
Yes not having a corpse visible is very annoying… have you tried the usual thing of running away from the area out of rendering view and then back to see if that prompts the game to render your corpse?
…have you tried harvesting randomly in the area you know you died to hit your invisible corpse and destroy it so a loot bag is generated?