Hello Bernard,
Do you mean that your aim is to:
1. Exit Hauptwerk completely (but not shut the computer down) upon pressing a particular MIDI piston on your MIDI organ console, and:
2. Relaunch Hauptwerk and re-load the organ upon pressing a different MIDI piston on your MIDI organ console?
If so, why do you want to exit Hauptwerk (if you aren't shutting the computer down)?