People who quit smoking have a 16% lower risk of dementia compared with those who continue, a new study has found.