This rule can be effective when the game is in background mode.. but theres also another rule for each 6 seconds a round passes and therefore theres a chance (idk exactly how much I'll look it up and I'll add it here later) to spawn a mob in your current map.
Which is disabled when you leave.. this rule controls both your health and conditions too..
My idea is to keep the 6 second rule enabled when you leave the game running in the background and keep the mobs spawning normally and your health regenerating until you come back

ofcourse that means you could be attacked but finding a good hiding spot from the mobs fixes the issue!