Fixing bug when finished gif generation