Mothballs can help to prevent a moth infestation in a rug, but it’s not the most recommended option, as mothballs contain chemicals that can be harmful to humans and pets. A better alternative is to use natural repellents like cedar blocks, lavender bags, and cloves.