Answer by taking a quote from the following article:

James Buchanan Jr. was born in a log cabin in Cove Gap, Pennsylvania (now Buchanan's Birthplace State Park), in Franklin County, on April 23, 1791, to James Buchanan, Sr. (1761-1821), a businessman, merchant, and farmer, and Elizabeth Speer, an educated woman (1767-1833). His parents were both of Ulster Scottish descent, the father having emigrated from Milford, County Donegal, Ireland, in 1783. One of eleven siblings, Buchanan was the oldest child in the family to survive infancy.

The Civil War erupted within two months of Buchanan's retirement. He supported the United States, writing to former colleagues that "the assault upon Sumter was the commencement of war by the Confederate states, and no alternative was left but to prosecute it with vigor on our part". He also wrote a letter to his fellow Pennsylvania Democrats, urging them to "join the many thousands of brave & patriotic volunteers who are already in the field".  Buchanan spent most of his remaining years defending himself from public blame for the Civil War, which was even referred to by some as "Buchanan's War". He began receiving angry and threatening letters daily, and stores displayed Buchanan's likeness with the eyes inked red, a noose drawn around his neck and the word "TRAITOR" written across his forehead. The Senate proposed a resolution of condemnation which ultimately failed, and newspapers accused him of colluding with the Confederacy. His former cabinet members, five of whom had been given jobs in the Lincoln administration, refused to defend Buchanan publicly.  Initially so disturbed by the attacks that he fell ill and depressed, Buchanan finally began defending himself in October 1862, in an exchange of letters between himself and Winfield Scott that was published in the National Intelligencer newspaper. He soon began writing his fullest public defense, in the form of his memoir Mr. Buchanan's Administration on the Eve of Rebellion, which was published in 1866.  Buchanan caught a cold in May 1868, which quickly worsened due to his advanced age. He died on June 1, 1868, from respiratory failure at the age of 77 at his home at Wheatland and was interred in Woodward Hill Cemetery in Lancaster.

What did he do in his final years?
The Civil War erupted within two months of Buchanan's retirement.