Working on method to be able to save imageArray when program is exitedshutting down application