cleanUp(); function cleanUp() { // // Initial cleanup: Close all windows. // This should recover as much memory as possible. It also ensures // the Results and Log windows are emptied. // What to do about other text windows? For now, just hope they're small... // write( "Closing Results window." ); // Force Results window to exist, since... selectWindow("Results"); // ... this crashes if window is absent. run( "Close" ); print( "Closing Log window."); // Force Log window to exist, since... selectWindow("Log"); // ... this crashes if window is absent. run( "Close" ); while (nImages()>0) { selectImage(nImages()); // This can crash when more than a couple large stacks exist, and we don't wait for GUI to finish. run("Close"); } }