OP, it is very hard to give you sound advice without specifics ... it is possible that you are being paranoid and the problem isn't THAT bad. After all, you said you "might" have caused the company money; you don't know for sure. So, OK, let's suppose you are correct and you might have screwed up big time. Here are the steps you need to take:
1) If you are suicidal about anything, please talk to a professional doctor, not strangers on the internet. You deserve help if you need it.
2) Accept that you probably will lose your job. Have a good 30-minute cry about it and then decide to be proactive. Update your resume, make sure you're contacts are in order and that you've backed up any files or information from your job that you are allowed to take with you. **Your main objective now is to not get fired for cause.** If you have to leave, let it be a resignation. That will make it MUCH easier to begin your job search.
3) Calm down and think logically. Try to come up with an honest answer as to how you messed up. Did you misunderstand the instructions or policy? Did you make an assumption? Did someone not explain something better? DO NOT attempt the blame game unless you can 100% prove you acted on incorrect information that was provided to you.
4) Come up with the best possible solution you can think of. Even if the solution is "the problem stops today because I've recognized my error", that's better than nothing.
5) Pick the supervisor or manager you feel most comfortable with and who you think will be most likely to at least listen long enough for your explanation without having a tantrum.
6) Request a private meeting as soon as possible. Rehearse what you want to say ahead of time. When you sit down with the supervisor, begin the conversation this way: "Thank you for listening, I have something difficult to explain. I want you to know that I realized I am mostly at fault for what happened and I am prepared to take full responsibility for what happened by resigning my position if there's no other solution". Then explain, as briefly as possible, what the error was, how the error happened and what your suggestions are to resolve it. Finish by apologizing and add that you are very grateful for the opportunities already extended.
At this point, it is in management's hands. But if you've been honest, handled it with class and courage and took ownership of your mistake ... you have a much better chance of getting another chance. If they want you out and you have to resign, then you will be able to leave gracefully, with your dignity intact and possibly with references still possible from colleagues (that's why you don't want to blame anyone!). When you job hunt, you can honestly say you left your last position to seek new opportunities which sounds tons better than "I got fired for a very expenseive mistake that damaged the company".
And finally, I wouldn't worry about the company coming after you unless you stole the money ... in which case you better be prepared to pay it back very quickly.