Usually everything goes smoothly, but be aware that you're putting yourself at risk.
You're liable for the outstanding debt and if the dealer doesn't pay it off, you're the one that's going to have to suffer the consequences.
I've heard a lot of horror stories from people who bought a new car and thought the dealer had paid off the loan on their trade-in. A couple of months later, they get a call from the lender asking for payment.
The worst case scenario is when a dealer goes out of business and they didn't pay off your loan. You could be fully liable for the payment.
The best way to protect yourself from this scenario is to pay off the loan yourself. Don't rely on the dealer to do it for you.
If need be, sell the car to a private party and use the sales proceeds to pay off the loan.
If you insist on trading in when you still owe money, have the dealer agree in writing that they will pay off the loan within 10 days or else the deal is off. If they refuse, don't do it.
Also make sure you sign a Payoff Authorization document. This allows the dealer to pay off your vehicle and have the title sent to them.
Follow up with the dealer and call your lender to make sure the loan has been paid off within 10 days.