Is it worth it to continue thinking about academia?
I am a Mathematician now working in Computer Security. Towards the end of my PhD, I gave a lot of thought to the problem you are suffering from right now, even though I enjoyed my PhD (for the most part ;-)). My conclusion was the following, and I think it still applies in your case; To stay in academia, you need to satisfy the following criteria:

You have to fairly evaluate your potential as a researcher, which includes your scientific intuition, the ability to execute on it, and your (social) network. Now deduce from this the potential position you can hope to ultimately land. You need to be ok with having that position for the rest of your life.
You have to be willing and able to go through the process of getting to that position, which I anticipated would include unpleasant post-doc experiences like the one you already mentioned.
Now comes the big one. In fact, you need to not only be &quot;ok&quot; with the position in (1), you need to be so incredibly dead-set on having that position that you are not deterred by the fact that (2) is not even the worst that can happen. You need to be so dead-set on it that you do not fear the possibility to end up in your mid-40s with absolutely no job experience and in a dead end that does not lead to new academic prowess.

The alternative is to get a job in the industry. If you do this, I want to give you one piece of advice: Do not look for a job that requires a lot of the specific subject matter expertise that you acquired as a researcher. Do not look for a job that is &quot;like academia&quot;. In short, do not fall prey to a sunk cost fallacy. Instead, look for the job you would have wanted fresh out of college. You have proven that you can learn a difficult thing, you can learn a new difficult thing.
Now, chase that job. Industry jobs have a much higher density than academic jobs, so laying out a career path to your dream industry job is much easier. It might be necessary to first work less perfect jobs, to acquire new skills, or simply because you do not have the experience yet. Nevertheless, there is a much lower chance of just falling off the edge and not having any prospect job at all.
In any case, I sincerely wish you the best of luck.