Fix for StackOverflow in closeMimeEntities()