A few ideas.
1> The plugin could be causing the issue, it may need to be shut down a certain way.
I know one of the physics plugins needs to be "stopped" in the script before you exit.
2> If you are using MALLOC in your script at all, there may be blocks of memory
still allocated, sometimes causes this issue.
3> If you are using MALLOC in your script at all, you may have "free"ed a block that was already free, this happens to me alot.
4> Disable any API programming if there is any, Ive sometimes had this crash come from apparently functional code.
5> Work intensive, but check though ALL you functions and make sure that if you have used a structure creator [ eg str_create() ]
that you dont lose its pointer at the end of the function without removing it [(str_remove()] first, unless you need to.
Ive gotten the crash you report when Ive been sloppy lke that.
6> Buy a wig... You'll need it after you pull ALL your hair out.
Best of luck