Closing the NPC trade UI should return to the NPC's dialogues
If you're still next to the NPC, closing the sell/buy/buyback menus with the X button seems like it should take you back to the NPC dialogue but you have to right click > talk
or walk away and back to talk to them again.