Fix error in terminate function.