I'm wondering if it's possible to listen in the background to if another application is running or not, and if it closes terminate the program?

I have a game launcher that I've made execute the game itself, and I want this launcher to keep running in the background to disable the use of particular keys while the game is running, and then run a couple commands once it detects the game closes and close itself.

Thanks ahead of time if you can point me in the right direction.