Going through a mid-life crisis may increase your risk of dementia, a study suggests.
Researchers found women who were happy and had high self-esteem in their 50s were less likely to develop the memory-robbing disorder by 70.
Positive women outperformed those who were stressed in middle age at thinking speed, memory and verbal tests.
The researchers say being happy and comfortable in your own skin encourages a series of healthy behaviours that stave off dementia.
Positive people brush off stress and anxiety, which have been shown to damage areas of the brain involved in emotion, thinking and memory, the researchers claim.
And having high self-esteem encourages you to be social, which builds up so-called cognitive reserve, the mind's resistance to damage of the brain.
Researchers from the Tokyo Metropolitan Institute of Medical Science analysed the records of 700 female baby boomers born in the UK after World War II.
The volunteers were part of the Medical Research Council's National Survey of Health and Development.
At the age of 52, participants filled out detailed questionnaires about their overall happiness.
They were quizzed on their job, relationships, purpose in life and self-acceptance.
At the age of 69 they underwent cognitive screening used to diagnose dementia.
It included tests on attention and orientation, memory, language and verbal fluency.
Those who had greater personal growth and self-esteem when they were 52 were more likely to have better cognitive scores 17 years later.
The link remained after taking into account other factors that increase the risk of dementia including education level, occupation, marital status, smoking and physical exercise.
Lead author Dr Miharu Nakanishi, from the Tokyo Metropolitan Institute, said: 'Midlife is a critical period for dementia-related brain changes and psycho-social crises.
'Psychological well-being can improve resilience to crises - yet it is not well understood with respect to dementia risk reduction.
'There was a significant association between greater personal growth and lower self-acceptance at 52 years - and better cognition at 69 years.'
Age UK charity director Caroline Abrahams said: 'The importance of this report is the connection it makes between positive mental well-being and better thinking skills in later life.
'Because our sense of mental wellbeing is something we can take steps to improve in the same way that avoiding things like smoking, excess alcohol or a poor diet can help to reduce the risk of developing some forms of dementia and cognitive decline.'
Recommendations include visiting friends or family, doing things you enjoy, staying active, eating healthily, volunteering and relaxing.
The findings were published in the Journal of Alzheimer's Disease.
In the UK around 850,000 people have dementia - a figure set to reach two milllion by 2050 because of the ageing population. In the US that number is around four million.