Flush screenshot image memory when GUI is closed