Blender doesn't run my script unless blender crashes?
It sounds like you have a bug in your script.  Run blender from the command line, and it will tell you what the error is there.

Update: I found that node in your code in the beginning of it, you have a several lines that say s_slots[0].material.node_tree.nodes['S_R_MS'].inputs[0].default_value = 0.0
I suspect that is where the S_R_MS node is.