Buying out lease, should I get a loan?

I have an Acura RDX and about $4500 in equity, so I am buying out my lease. I am on the fence about getting a new car. I find the RDX annoying in a few ways, but also it is a nice car, my needs are low, and it is a bad time to buy a car. I have the cash to buy it out, it’s about $31,000.

Here’s my problem: if I do trade in the car, I don’t want to put the entire $36,000 value of the car towards a new lease. I’d want some cash back. But I would like to trade it in, in part, to get the sales tax benefit. I have a vague memory that I did get some cash back when I traded in my very old car when I leased the RDX, but the numbers here are way different. Does this make any sense?

Am I better off getting a loan so that the loan gets paid off at trade-in and only the equity goes toward the new car? Or am I better off not getting a loan, losing the sales tax benefit, and just selling for cash, probably to CarMax?

(Open to thoughts on an RDX-comparable plug-in hybrid with a less annoying infotainment system)

Thanks!