The official surrender document of Lee's troops to the Union Army, signed at Appomattox Court House on April 9, 1865:
We, the undersigned Prisoners of War, belonging to the Army of Northern Virginia, having been this day surrendered by General Robert E. Lee, CSA, Commanding said Army, to Lieut. Genl. U. S. Grant, Commanding Armies of United States, do hereby give our solemn parole of honor that we will not hereafter serve in the armies of the Confederate States, or in any military capacity whatever, against the United States of America, or render said to the enemies of the latter, until property exchanged, in such manner as shall be mutually approved by the respective authorities.
Done at Appomattox Court House, Va., this 9th day of April, 1865.
General Order Number 9 served as Lee's farewell address to his army. The order was distributed the day after the official surrender of the Confederate Army at Appomattox Court House.
Hd Qurs Army Northern Virginia 10th April 1865.
After four years of arduous service, marked by unsurpassed courage and fortitude, the Army of Northern Virginia has been compelled to yield to overwhelming numbers and resources.
I need not tell the brave survivors of so many hard fought battles who have remained steadfast to the last, that I have consented to this result from no distrust of them, But feeling that valor and devotion could accomplish nothing that could compensate for the loss that would have attended the continuance of the contest, I determined to avoid the useless sacrifice of those whose past services have endeared them to their countrymen.
By the terms of the agreement, Officers and men can return to their homes and remain until exchanged. You will take with you the satisfaction that proceeds from the consciousness of duty faithfully performed and I earnestly pray that a merciful God will extend to you His blessing and protection.
With an unceasing admiration of your constancy and devotion to your country, and a grateful remembrance of your kind and generous consideration of myself, I bid you all an affectionate farewell.
R E Lee
Source: Lee, Robert E., Jr, Recollections and Letters of General Robert E. Lee.