Ge. Robert E. Lee surrenderd to Gen. Grant at Appomatox, VA. There were a few other military forces that did not surrender at that time, but his surrender effectively ended the Civil War. Why did he surrender? His forces no longer had the ability to do battle.
The surrender of General Robert E. Lee to US general US Grant at Appomattox, for all practical purposes marked the end of the US Civil War. "All Practical" is used because technically, not until May of 1865, did all of the South's forces surrender.
Generally speaking the surrender of Robert E. Lee to US General Grant is referred to as the surrender at the Appomattox Court House. Lee's surrender was the key which in all practical terms ended the US Civil War. Later other Southern armies would surrender.
General Lee did not "surrender the Civil War". He surrendered his army, the Army of Northern Virginia, when it was clear that he could no longer effectively fight against the Army of the Potomac commanded by Ulysses Grant.