fix Issue 9788 - -profile doesn't work if exceptions are thrown in the r...

...unning program

fix http://d.puremagic.com/issues/show_bug.cgi?id=9788