The success of Grant's policy of attrition. He ended the system of prisoner-exchange, and then more-or-less waited for the Confederates to run out of manpower.
There had also been a lot of desertions from Lee's army, especially from troops who lived in Georgia and South Carolina, when they heard about Sherman's campaign of destruction in those two states.
The arrival of Phil Sheridan from the Shenandoah added a new spirit of aggression to the Union troops. It was Sheridan who stopped Lee from joining up with Joe Johnston in North Carolina. He just kept shunting him West towards nowhere in particular, until the end came at Appomattox.
Chat with our AI personalities
The Confederate capital, Richmond was captured after the Battle of Five Forks, which forced Lee to evacuate it and Petersburg as well.
Petersburg
Why was philip sheridans victory at five forks a disaster for lees army
The Union Army managed to break through the Confederate lines at Five Forks, menacing to outflank Lee's Army right wing. That forced the Confederates to abandon Petersburg and evacuate Richmond to prevent them being encircled. Some 30.000 Confederates troop began to retreat westward along the Appomattox river, giving the start to the last stage of the war in Virginia, which culminated with Lee's surrendering at Appomattox Court House on Apr. 9,1865.
By defending Petersburg throughout a nine-month siege.