The only real way to change these patterns is through therapy. Medications are helpful for some with this kind of problem, but not always. To use an analogy, taking a medicine for this kind of problem is like wearing a band-aid to prevent an infection. The actual treatment you need is with a psychotherapist. The kinds of therapy most helpful are called STEPPS/STAIRWAYS and DBT. When you go looking for a therapist, you should ask if he/she is trained in either method.
Good luck to you.
As always, if you feel like harming yourself or anyone else in any way, you must immediately call 911, or go to the nearest emergency room.
Please remember that I cannot make a diagnosis based on internet communication.
Dr. K. Eisele