Fix a potential issue with cleaning up if a PNG image fails to load.