fix close function bug