Quick answer
Leave. The verse gives permission to end a conversation that is not going anywhere, and it is one of the few pieces of straight tactical advice in the chapter.
Read both lines
The counsel is practical rather than moral, and it follows from 9:7's observation that correcting a scoffer only costs the corrector. The condition in the second line matters: you go when you do not perceive knowledge in him, which makes this a judgment call rather than a policy of avoiding people. Nothing here licenses writing anyone off as a category. It describes a specific conversation in which nothing is being exchanged, and it says your time is worth more than continuing it.
Related: Proverbs 9:7–8 · Proverbs 13:20 · Proverbs 23:9
New King James Version®, Copyright © 1982, Thomas Nelson. All rights reserved. Full copyright information. Scripture provided by API.Bible.
Go Deeper
If this verse has been used to put weight on you that it was never carrying, ask about it directly.