This has happened to me twice now and I can't explain why. One was under the circumstances of being turned into a corpse when I was Baeful Polymorphed, and now I experienced this bug again when crashing due to an EE bug, and dying to a mass of enemies while flat-footed. When I logged back in, I died as you do if you crash or log out while bleeding, but then I went into the Near Ethereal alive. I could cast spells and do just about anything except rest. Even when in the game world, it says that I cannot rest at this time.
Alive in the NE:
Cannot rest:
Logging back in after a time seemed to revert me to ghost state after I entered the world, so it seems there is a bit of a safety net with the death script. I am not so sure this is a character-specific bug I am encountering, or only something that seems to happen when very specific circumstances are met. Regardless, this is the best documentation I can provide on this rather frustrating bug.
Returned to the NE after log in:
As an aside I came back as a zombie when someone tried to resurrect me. This happened twice as well if I recall my previous experience with this bug.