Answer by taking a quote from the following article:

George Armstrong Custer (December 5, 1839 - June 25, 1876) was a United States Army officer and cavalry commander in the American Civil War and the American Indian Wars. Raised in Michigan and Ohio, Custer was admitted to West Point in 1857, where he graduated last in his class in 1861. With the outbreak of the Civil War, Custer was called to serve with the Union Army. Custer developed a strong reputation during the Civil War.

In 1864, with the Cavalry Corps of the Army of the Potomac reorganized under the command of Major General Philip Sheridan, Custer (now commanding the 3rd Division) led his "Wolverines" to the Shenandoah Valley where by the year's end they defeated the army of Confederate Lieutenant General Jubal Early in the Valley Campaigns of 1864. During May and June, Sheridan and Custer (Captain, 5th Cavalry, May 8 and Brevet Lieutenant Colonel, May 11) took part in cavalry actions supporting the Overland Campaign, including the Battle of the Wilderness (after which Custer ascended to division command), and the Battle of Yellow Tavern (where J.E.B. Stuart was mortally wounded). In the largest all-cavalry engagement of the war, the Battle of Trevilian Station, in which Sheridan sought to destroy the Virginia Central Railroad and the Confederates' western resupply route, Custer captured Hampton's divisional train, but was then cut off and suffered heavy losses (including having his division's trains overrun and his personal baggage captured by the enemy) before being relieved. When Lieutenant General Early was then ordered to move down the Shenandoah Valley and threaten Washington, D.C., Custer's division was again dispatched under Sheridan. In the Valley Campaigns of 1864, they pursued the Confederates at the Third Battle of Winchester and effectively destroyed Early's army during Sheridan's counterattack at Cedar Creek.  Sheridan and Custer, having defeated Early, returned to the main Union Army lines at the Siege of Petersburg, where they spent the winter. In April 1865 the Confederate lines finally broke, and Robert E. Lee began his retreat to Appomattox Court House, pursued by the Union cavalry. Custer distinguished himself by his actions at Waynesboro, Dinwiddie Court House, and Five Forks. His division blocked Lee's retreat on its final day and received the first flag of truce from the Confederate force. Custer was present at the surrender at Appomattox Court House and the table upon which the surrender was signed was presented to him as a gift for his wife by General Philip Sheridan, who included a note to her praising Custer's gallantry. She treasured the gift of the historical table, which is now in the Smithsonian Institution.  On April 25, after the war officially ended, Custer had his men search for, then illegally seize a large, prize racehorse "Don Juan" near Clarksville, Virginia, worth then an estimated $10,000 (several hundred thousand today), along with his written pedigree. Custer rode Don Juan in the grand review victory parade in Washington, D.C. on May 23, creating a sensation when the scared thoroughbred bolted. The owner, Richard Gaines, wrote to General Grant, who then ordered Custer to return the horse to Gaines, but he did not, instead hiding the horse and winning a race with it the next year, before the horse died suddenly.

What is the valley and appomattox