fix error in termination from script re-run