Run an empty cycle without clothes in your washing machine, adding two cups of apple cider vinegar to the load. It will help remove gunk and detoxify it by staving off bacteria.
If the stench is coming from the rubber gasket, mix one cup of apple cider vinegar with one cup of baking soda, stir it, and use it to clean inside the rim with a cloth or a brush.
For regular maintenance, run apple cider vinegar through your washer every three to four months to keep it in good-smelling condition and to ensure it lasts longer.