The decision ends a racist practice that dates back to the end of the Civil War.