People with opioid use disorder (OUD) can stop using opioids on their own, with help from groups and with treatment, but there is limited research on the factors that influence opioid cessation. We employed multiple machine learning prediction algorithms (LASSO, random forest, deep neural network, and support vector machine) to assess factors associated with ceasing opioid use in a sample comprised of African Americans (AAs) and European Americans (EAs) who met DSM-5 criteria for mild to severe OUD. Values for several thousand demographic, alcohol and other drug use, general health, and behavioral variables, as well as diagnoses for other psychiatric disorders, were obtained for each participant from a detailed semi-structured interview. Support vector machine models performed marginally better on average than those derived using other machine learning methods with maximum prediction accuracies of 75.4% in AAs and 79.4% in EAs. Subsequent stepwise regression analyses that considered the 83 most highly ranked variables across all methods and models identified less recent cocaine use (p<5e-8), a shorter duration of opioid use (p<5e-6), and older age (p<5e-9) as the strongest independent predictors of opioid cessation. Factors related to drug use comprised about half of the significant independent predictors, with other predictors related to non-drug use behaviors, psychiatric disorders, overall health, and demographics. These proof-of-concept findings provide information that can help develop strategies for improving OUD management and the methods we applied provide a framework for personalizing OUD treatment.