Seriously. I've been cheating because of this. I really don't find it any difficult to afford things in shops if I don't lose my things when exiting, YET I LOSE SQUARES IF I DIE, BUT NOT ITEMS?
I think you should only keep what you get if you EITHER: reach a respawn point afterwards, or you finish the level/given tasks.