The Matrix

First off, Neo is able to kill the Machines because he is able to control anything associated with the matrix, and since the machines are, in one way or another, associated with the Matrix he can kill them.
Neo is going to the machine city to make peace with the machine boss. He makes a truse with the boss when he says that he will kill Agent Smith, since he is going out of control and is trying to kill everything and everyone. Neo also promises to give them his body which contains the coding to restart the matrix. He does this in hopes the machines will halt their attack on Zion.
In his battle with Smith. First of all, NEO and SMITH are the same person, when Neo killed smith in the first matrix, part of Neo\'s code went into Smith and he became Neo\'s alter ego, in a way. This battle between the two was to prove to everyone that the both of them are unbeatable and that they would fight forever, that is why Neo gives up.
Neo and Smith are the same person as i said before, Neo is supposed to be the Good, or positive side, while Smith is the Bad, or negative side. Since Neo gave up, Smith, who is also the cloned Oracle, freaks out and acts all weird because he can see the future and Neo was not supposed to give up but continue fighting. Smith assumed he was supposed to now clone Neo, he was wrong. The Smith\'s eventually blow up, this happens because since Neo and Smith are the same person, they cancel each other out. Neo is Positive and Smith is Negative, think of it as 1 plus -1 equals 0, Neo knew this and this is why he gave up, it was the only way to beat Smith.
Now since they are both dead, the machines take Neo\'s body so they can use his code to restart the Matrix, like he was supposed to do in RELOADED. This time however, since Neo made a truse with the machines Zion would not be destroyed.
When the matrix is rebuilt, the Oracle and the Architect discuss things. She and him agree that the 1% of people that reject the matrix will be allowed to get out and live freely in Zion, and the other 99% who make the CHOICE to stay and live in the matrix, can do so. This is supposed to be the Theory of CHOICE discussed in RELOADED.
THis is supposedly a happy ending in that the people who want to be free can be free and the war between the machines and humans is over.
This is confusing and makes you wonder why the machines just stopped the battle in Zion, but that\'s the way it is.
This is the ending, and if you have any questions just ask and i Will gladly try to answer.