I don't know why you would have lost any gold. You get xp back by completing your death quest.
If you log out while dying, you'll be dead when you log back in.
Sometimes, you may log out, crash out, server time out while in combat, only to find yourself dead when logging back in. This just happened to me recently. I was fighting some kittens, crashed, logged back in to find myself bleeding to death in the start tent. Didn't make any sense to me, but apparently even if you're lagging/crashing on your side, the baddies can still kill you.
