How can I finish my PhD? I have M.Sc. in mathematics, and I was/am working on a PhD for almost 10 years now (on and off), but I haven't published a thing. I have many results (most in a single field) and potential paper drafts, but I never finish up and publish, because I always find something new to learn or a new problem to research. I left the university eventually and got a part-time job as a data scientist, but I was never satisfied about leaving things open. I was working completely alone and didn't get along well with my adviser.

Today, while I have the time, I lack the discipline and environment to finish. None of my close friends are mathematicians, so I can't really talk about math with anybody (besides Internet forums). I love math very much, and I'm learning new things all the time, and I want to have my results finally out there and have my resume match my skills.

I will be glad to hear any advice, if anybody was in a similar situation. Any help will be appreciated.
Do not get distracted and focus on completing a thesis rather than publishing. After 10 years, you should have enough material to write a decent thesis, even though what you have done may not be publishable. Get support from your supervisor and anyone supportive from the your department to achieve this. Otherwise, self-fund or reach out for coaches or mentors are able to achieve this aim. Ideally people that know your area and can help support you to focus on your thesis rather than the publications. 

I understand and respect that publication is important especially in mathematics. Publications is the focus for an academic career but you have already invested 10 years of your life and it does not sound like you are going to be hitting a string of publications soon. Also, if you are already working part-time, it seems to me, getting the PhD and then working full-time is a very reasonable and respectable career goal. 

Recognise that you get a high every time there is a new challenge. Every one does. It is far more exciting to mov from one exciting topic to the next. Every new challenge has a buzz to it. You have to decide whether this buzz and excitement is more important than completing your PhD. Going over old material and old "stuff" would be drudgery and probably your previous traumatic experience (as you remember why you were not able to achieve publication), but it is important to swallow your pride and decide whether completing a thesis and your PhD is more important than achieving the goal of publication.