Sometimes we simply have to stop. So, know how to stop. It may take clear-headed thinking, another individual or circumstances to make us stop. To keep investing time, energy and money is to get diminishing returns or worse, nothing at all.
Having the good sense to call a halt is a tough decision. But you can do it, and from time to time you must. Whatever is invested to this point can be added up to experience learned. You have now learned how not to do it, and that is a valuable lesson that will stick with you for the rest of your life.