is there a way to take a pet out of a battle other than having them lose?
You can go to the Statistics page and click forfeit battle instead of just losing. It still counts as a loss on your record but you'll still be left with whatever HP left you had in the battle rather than 0.