function close_all
%function close_all simply closes the current graphics window and all
%windows whose handle is a smaller integer.
%BUGS:
%1) If there are no windows open then close_all will cause the screen to
%blink by opening a window and then suddenly closing it.  This is due
%to a bug (feature) in matlab whereby if you use the commands figure
%or gcf to get a figure handle when there are no open graphics windows
%then figure 1 will be opened.
%2) All graphics windows with handles greater than the current one will
%not be closed.

lim = gcf;
for ifig = lim:-1:1
  close(ifig)
end
