It's not a dream at the end. He remembers how he got there. In the first part of the movie he specifically explains that in the dreams, you never know how you got there, you just appear.