i'm interested in that too, though I suppose it's the kind of thing that's built for an OS to do..
e.g. in windows a bat file could do something before it runs, run it, then do something after it runs. Or jscript/vbscript, a .js file or .vbs file, could launch sublime, and do something before and after(with no cmd window popping up). Bear in mind also that an application can be closed with tasklist /f /im blah.exe and it's closed before it knows what hit it. So to really know it has just closed, the wrapper method provided by the OS, OS scripting, seems good.