Fixed potential deadlock in MATLAB window