Fixed terminate bug (I think)