I have one coworker like that. Ask him for help and be ready for a 20 minute talk. Or him trying to do the work for you. He is quite smart though and what he says is often interesting. Still, thanks to him I got to practice extracting myself from long talks :-)
I would suggest two approaches :
1. Be more direct
It feels rude to just make a request so that's why many people don't think they can do that, but as long as your tone is warm and friendly, it shouldn't be a problem, reasonable people don't react badly to a reasonable request. Thank them, say their help is welcome, but that you need to go. If you think it will help you, show them you appreciate their help by suggesting you'll ask for it in the future again. In this case, you could have said something like that :
Hey Helpie, thanks for your help, but I need to take a break now. If I'm still stuck later on, I'll come pick your brain again if it's allright with you.
If you don't have to go on a break but just want to continue searching on your own, you can also do that (although it depends on the person and what relationship you have with them). Again thank them for their help, that it was useful, and frame it as freeing them from this :
Hey Helpie, thanks for your help, talking with you has made some things clearer, so I'll take it from here and let you get back to work. If I'm still stuck later on, I'll come pick your brain again if it's allright with you.
If they still won't move, you can still try to be a bit more forceful in your wording, but still keeping a warm and friendly tone, even joking a bit if you feel it will go over well with the helper. Also at this point, don't hesitate to make something up and that you need to do another task that has nothing to do with this. You can even suggest keeping them in the loop of this problem.
I'm glad you find this problem so interesting, but I really need to take a break / get back to work / check something / ... I didn't plan on taking so much up of your time and I need to go now. But thanks a lot. If you want to I can tell you when I find a solution for this.
If they still don't leave, they are being very rude. It's ok to be more curt then ("Hey did you hear me ? I need my computer back now") or stick with an excuse of why you need to leave. If they say to leave your computer, say your not comfortable leaving your computer unattended. This is very common in a lot of places, it wouldn't even cross my mind to keep working on someone else's computer when they aren't there. If you're in a company where people do that, frame it as this being a quirk of yours (instead of the boundary violation that it is).
I know it's weird, but I don't like people being on my computer when I'm not there. Thanks for your understanding.
2. Make up something
If you just want to continue working alone but aren't comfortable telling your coworker that, or you know that they won't respond well to your honest request, just make something up. Go direct to the last option of the previous approach and make up a reason why you need your computer back and want to be alone. You have a meeting, there's another task that demands your attention you forgot about... Again, thank them for their help, that it's much appreciated, but that you forgot something and you need to get back to work. You can even reach your computer while doing so, making it obvious to the helper and leaving them little opportunity to stay.
The approach you choose depends on what relationship you have with the helper(s), and what you know about them. The colleague I was talking about has no problem with me telling him that I just want to continue working on my own, I'm comfortable just telling him I need to go. If he's on a rant and isn't really listening, then I make up something that I absolutely can't stay (meeting, task, urgent bathroom break) and just start leaving.