If you notice that your closed terrarium has pests, the bugs were likely present on the plants before they were added to the terrarium.
Air-tight terrariums don't attract bugs, but open terrariums can be affected by gnats, mites, or mealybugs. Overwatering is usually the cause, so keep your terrarium balanced to ward off invaders. If you notice that your closed terrarium has pests, the bugs were likely present on the plants before they were added to the terrarium. It's a good idea to always check your plants for bugs before planting your terrarium, and apply a preventative insecticide to the plants beforehand if you are worried.