Well... he didn't. It is a common misconception that Lee's surrender was the end of the war, but it really wasn't. He surrendered the Army of Northern Virginia, and not much else. As the flagship Confederate Army, it was a crippling blow to the Southern cause, but it wasn't exactly the end of the war. Rather it was the catalyst for the rapid collapse of Confederate forces in other theaters. Johnston wouldn't surrender for two more weeks, and the last major Confederate force were the men under Stand Watie, in late June.