add App Terminate code