I have a script that creates a waiting UI bar for the time of the for loop:
wb = waitbar(0,'Name','My waitBar');
for t = 0:t_end
waitbar(t / span(end), wb);
However, when I try some things in do_stuff, I sometimes (often) have errors. So the script stops, but the UI windows remain and is impossible to close.
I thought a try/catch thing, but is there an easier way to get rig of those ghost windows?