Actions on abnormal termination

Hello everybody,
I am trying to make a program that simulates certain keystrokes on another program. My problem is that if the user terminate abnormal and sudden the program (Ctrl+C) then sometimes the Alt button get stacks at the down position.
What i need to know is, if there is any way to perform some actions at the end of the progam, even if it finish abnormal like the above situation. I tried this example:
1
2
3
4
5
6
7
8
class KeepRunning {
  public:
    ~KeepRunning() {
      // Whatever code you prefer to keep the program running, e.g.
      cout << "Program shutdown...";
      system("pause"); // "Press enter"
    }
}RunFlorestRun;

from post http://www.cplusplus.com/forum/beginner/1988/ but i doesn't seem to work if i press Ctrl+C.
Is there any way to do something like that?

Thanx
Topic archived. No new replies allowed.