In my experience, exit() kills MATLAB. I usually rewrite my code in such a way that I can just use a return from it instead so that I can collect the output string.
(I'm sure there may be reasons why you can't do this in your application. If so, then I am just commenting here so I will remember to look back if other people have better answers...)