If you or your family member has difficulty becoming discharged, call the Ombudsman, the State Regulatory agency (a full listing is located in the Nursing Home Survival Guide, and the number of the agency is posted in a public area of the nursing home), or even feel free to call an attorney. The nursing home can't legally block you from leaving nor can they threaten or attempt to intimidate you.
The worst thing that can happen is that the doctor will refuse to help you leave, and you'll have to go to your primary physician for prescriptions or in-home care. If the nursing home refuses to allow you to leave, call the doctor in charge of your care on your own. He might not even know you want to leave - and once you explain the situation to him, he'll probably help you with the discharge.