From what I have heard is this...
When a Jedi is ready to die their body will vanish into thin air. They're giving themself to the Force, to make it an even more powerful entity. That's why Obi-Wan and Yoda both vanished. They were ready to die.
When a Jedi is killed in battle unexpectedly their body doesn't disappear. That's why Qui-Gonn and Darth Vader (even though he really wasn't a Jedi) didn't disappear when they died. They were not read to die voluntarily on their own, and they were both unexpected deaths.