Maggots hatch from the eggs of the common housefly. Foul smells attract flies who relate them to food supplies, therefore maggots are often found on foods that are left rotting as well as on animal carcasses. The life cycle of a maggot is fairly short before it turns into a fly but if you want to kill the maggots, flood them and their food source with salt to eliminate their water source.
Preventing maggots is the key to keeping them away from your home. Flies only lay their eggs on food sources so it is essential to keep edible material covered when not in use. When you put food on your kitchen counter during months when flies are abundant, use sealing containers or cover your food with plastic wrap.
Use a garbage can with a lid in your kitchen. Disposed food is especially attractive to flies because it is not surrounded by human disturbance. It is also important to use a thick garbage bag so you can prevent tearing, as any opening in a garbage bag is an easy access point for flies. You can use rock salt as a preventive measure, by sprinkling it over the garbage can, to prevent flies from coming in.
If you notice maggots in your garbage area or around your home despite your efforts to prevent them, use a large amount of salt to destroy them. Maggots thrive in warm, moist areas, so sprinkling salt on and around their space eliminates moisture and water so they are unable to prosper.
This method is excellent for eliminating maggots from a confined area, but it may not be as affective in an open space. If you have a large backyard and an animal carcass on your property that has a maggot infestation, you can sprinkle the remains with a large amount of salt, but the maggots will be able to disperse and find a new food source.