It’s all treated the same way. Though your IRA may be in multiple accounts, you essentially have 1 IRA. If some of the contributions were non-deductible, some were deductible, and some were from a roll-over, it’s taxed as if you have 1 IRA. So it’s non-deductible contributions (less previous non-taxable recovery)/value of all IRA’s at the beginning of the year to determine taxable portion of all IRA distributions. You can’t pick and choose when you recover the basis tax-free.
So as a practical matter, you can’t recover all the basis until you take a final IRA distribution.