fix #640, bug in terminate statement