After 3 years... Should I stay at a PhD position that I think is holding back my thesis? I was supposed to do my thesis in a research department of a company in the field of computational science (developing new computational methods that they could use to design and engineer nanostructures). In parallel I registered as a PhD student in computational physics (my undergrad studies) at a University nearby.

In practice I have spent 3 years developing software for them, with no contributions of my own, just taking already published research and making software out of it. I only have 2 co-author papers, on another field and a topic that I can't really use for my thesis.

I am unable to publish by myself in this field, as experiments are usually required and I have little experimental support from my boss (he disregards any of my ideas, and just wants me to pursue those things that would benefit the research of someone else, work that for me does not answer a "scientific question"). I'm also hating right now my job, the first year I could learn some things, but now is just coding to make the "user experience" better. 

I have also tried to get involved in other experiments, but my ideas are taken and carried out by someone else (even if I insist a lot on doing them). I have also proposed small projects, but usually anything is disregarded by my boss with the pretext that it would take "too much time" (for example, I offered to do a small complementary data analysis for an experiment in 3 days, he said no, it was too much time, it was months ago and they haven't finished the data analysis yet). He has also had me studying for some months different techniques difficult to master and later told me to drop it as it wouldn't fit our project requirements (FE, MD, QM/MM...)

I know it is mainly my fault for not having been more aware that this was happening (it started more clearly after the 1st year), I spoke with my boss a number of times but that didn't change anything. I doubt he read my thesis proposal. He always answers that the software will be published in very high impact factor journals (he has little to none high impact factor publications so far) and therefore I would be able to get a thesis with it since no one will question a paper published in one of the top journals (the contribution is purely the software as all methods were already developed). I don't believe this, for me it sounds like bullshit (that it will publish this well, and that in this case it wouldn't be question as not answering a scientific question, which is the requirement for a thesis in my field).

On top of this the environment at my group is quite bad for me. One colleague is not even speaking to me and no one is coming from my field, so I'm professionally isolated.

Due to this I finally reacted and started collaborating a few months back with a group in a university here. They have let me on a project and I'm learning a lot and having fun. My boss obviously doesn't like it and has tried to push me away (including a 3h meeting). In few months my contract runs out and I will probably get an extension offer from my boss for half a year more, if I take it I'm pretty sure this collaboration would have to be entirely in my free time (I work full-time on my "thesis" position).

So far it feels that my job, which should be doing my thesis, is actually holding back my thesis and that they are using me as a low-cost programmer. But it is the only financing I've got. Also, by now is impossible to carry on the thesis proposal I submitted, although if I manage to get some papers out from the collaboration, I can manage to save it.

So what should I do? Give it up entirely and look for another PhD? Give it up and forget about the PhD (maybe I'm not made for this)? Try to finish on my own and look for a part-time job meanwhile or tell my collaborators? Accept the extension and continue knowing how things are and trying to somehow get some papers published so I can leave with a thesis? I feel that I already made too many mistakes in handling this, and one more could put a definite end on my research career.

Thank you if you read this.
The situation you are in is unsustainable. If you let it happen they will continue to abuse you forever. Evaluate the various people around you and separate those that are supportive from those that are not. If it is your academic advisor that is supportive then you might have a path in your current program, but if not, you need to find a way to exit. 

You don't give any evidence here that you are unsuitable for continued study, but you need to take a more proactive stance to realize your goals. 

Not every place is like what you are experiencing, nor is every boss or advisor an exploiter of students. 

But take stock of your options and don't be shy about moving on.