I feel that Anakin Skywalker and Mace Windu both died simultaniously. That is why the young Anakin ghost appears at the end of Jedi. He ceased being a Jedi at that moment and fully embrased the Dark Side and his new name, Darth Vader. I think his spirit went in "limbo" at that point, maybe helped by Qui Gon or something. He had little traces of good in him still as Darth Vader, but it wasn't until he saved his son at the end of RotJ that he redeemed himself and his spirit was set free. He had for the most part done no good as an old man, which is why the spirit appeared as it did.