The same medication is often given to dementia patients to help manage its frustrating symptoms