Yes, a great deal of the reason the states seceded was to keep their slaves, but there are indications that slavery would have ended anyway in those states, even without the war.
In addition, the Confederate Constitution banned the African/American slave trade. There was no interest in buying more slaves.
From the Confederate Constitution:
Sec. 9. (I) The importation of $#@!es of the African race from any foreign country other than the slaveholding States or Territories of the United States of America, is hereby forbidden; and Congress is required to pass such laws as shall effectually prevent the same.
(2) Congress shall also have power to prohibit the introduction of slaves from any State not a member of, or Territory not belonging to, this Confederacy.
https://avalon.law.yale.edu/19th_century/csa_csa.asp
Less than a third of people living in the Confederate states owned slaves, and the majority of that small number who did, owned very few. The wealthy slaveholders were the ones who wanted to keep slavery alive at that time, although even they were not interested in seeing it grow. It was dying, and it was only a matter of time before abolitionists made greater headway in those states.
Remember, the northern states owned slaves as well, and those slaveholders fought tooth and nail to keep their slaves, but the abolitionists methodically worked to ban slavery. The abolitionists were also active in the Confederate states and they, too, would have been successful, given time.
This is true of course, which demonstrates that the North held no moral high ground. Their reasoning was purely economical.
When slaves in the Confederate states were emancipated, slavery didn't end, however. The Union-border states still owned slaves for a while longer, so, in reality, the Union owned slaves the longest.