Way to go. I believe you made the best decision to protect yourself. His behavior sounds quite scary.
Please be careful to protect yourself even after the restraining order. It is only a piece of paper and it doesn't stop some from continuing the crazy behavior.