Two classes of medications used to treat insomnia, Benzodiazepines and Nonbenzodiazepines, can be habit forming. This means that when these medications are taken for an extended period of time, the body will become dependent on them to sleep. Stopping these medications can be difficult and cause withdrawal symptoms. For this reason, they are classified as controlled substances and have strict restrictions on how they are prescribed.