Fix crash when writing epg cache to the disk