Brody learned that the CIA wants him gone after they think that the mission failed. He then comes to Abu Nazir's wife, Nassrin, and convinced her to setup an emergency meeting with Danesh Akbari by saying that he has information about Majid Javadi. It looks like that Brody really intend to burn the mission down by exposing the CIA's plan and Javadi. Only until when they are alone in the room and he realized that he can kill Akbari did we know that the mission is still on.
Now, did Brody really intend to kill Akbari in the finale or was that just a sudden change of heart when he thinks he got a chance to escape.