handle code and reason of terminate message