I always love to remind people that FIVE SLAVE STATES remained in the UNION, as SLAVE STATES.
After Lee surrendered, several of those states remained SLAVE STATES until the passage of the 13th Amendment eight months after the war ended.
So the last flag to fly over legal slavery in the USA was the stars and stripes.
You are right that Lincoln’s emancipation proclamation did not apply to the “border” states that had slavery. Maryland, Missouri, West Virginia, and Tennessee were exempt.
In addition, Delaware and Kentucky ended slavery when the 13th ammendment was ratified in 1865
It also flew the longest of the two. It flew for "Four Score and Seven years" of slavery.