Added terminate event listener.