fix a bug for teminate operation