Walker served on court martial duty in the Department of Richmond from November 7, 1864. He was assigned to the defense of the Richmond and Danville Railroad during the Siege of Petersburg from February 1865 to the evacuation of Richmond on the night of April 2, 1865 after the fall of the defenses of Petersburg, Virginia at the Battle of Five Forks and the Third Battle of Petersburg. He was reported to have brought the news of the surrender of General Robert E. Lee and the Army of Northern Virginia at Appomattox Court House on April 9, 1865 to Confederate President Jefferson Davis at Danville, Virginia. Davis ordered Walker to take the Confederate troops at Danville to join the force of General Joseph E. Johnston in North Carolina but Walker apparently did not comply with the futile order or was unable to comply with it before Johnston surrendered to Union Major General William Tecumseh Sherman on April 18, 1865 (officially April 26, 1865). Walker was paroled at Richmond, Virginia on May 7, 1865.