fix terminate event