There is nothing that you could have done to change the situation.
His demise is a result of his choices. He made choices that impacted your decision to leave the relationship. Choices that made you feel unsafe. You offered him options. He chose not to participate in the options you offered, and chose to continue on a path that you could not join him on.
What happened is sad. It is a fate that we hope none of our loved ones come to, but there is nothing to regret. His choice was to use. He knew the risk involved could have been fatal. Of course no one thinks it will happen to them...human nature...but he chose his fate.
Please don't beat yourself, up with with would have or could haves. As you said....it is what it is...it was what it was....and he chose what he chose.
My heart goes out to you. Please take care of yourself, and thank you for sharing your story. Perhaps it will help someone who needs to hear it. You are very generous to give when you are in pain and feeling weary. Thank you.