Although we only see Gandalf die and return once, he actually died seven times throughout the Hobbit and Lord of the Rings. He was constantly shuffling back and forth between Valinor and Middle Earth. When he disappeared in the Hobbit briefly before the encounter with the trolls? Died. When he went off to get help for the battle of Helms Deep? Died.