How can meds be disposed of safely?

When opioids or other painkillers prescribed after surgery or an injury are no longer needed, or if a medication was changed, patients may have unused prescription medications in their homes. Is there a safe way for patients to dispose of these leftover prescriptions?