Fixed a bug where the image storage thread quit before storing all images.