Package files, then deleting them

How would i have a script open an installer, and then when installer quits, the file is deleted? I know how to open the files. Just need to know how to delete the package file when installer quits.