Fix a bug causing exceptions when the debugged program terminates