Updating the terminate function.