Where are you doing this check - in a parallel process common event? Are your battles set by random encounters on the map, or do you have monster events and use the Call Battle Processing command? With monster events, you can check the 'continue when defeated' flag and call a common event in the 'on lose' condition.
Doesn't your game go to game over when the whole party is defeated? If it does, you're going to have to do something to change that, otherwise your save file will contain your gold PRIOR TO the battle.
Anyway, assuming you can get an event to run after the entire party is defeated in battle, just do a Conditional Branch, select Script, and type $game_party.all_dead?