fixed terminate/2 bug