Fix for div not closing and deleting contents