fix bug for exit