THE head of NHS Scotland revealed that the deaths of his mother and father within five months of one another earlier this year spurred his decision to step down from the "24 hours a day, seven days a week" role.

Paul Gray, who will leave the posts of chief executive of NHS Scotland and director-general for Health and Social Care in February, said it had led him to take stock after 40 years as a public servant.

Read more: NHS boss says Lesley McLay's £91k pay-off from Tayside 'good value for money' 

Mr Gray, 56, said: "In the course of this year, 2018, my mum passed away in May and my dad passed away in October, within five months of each other.

"It made me think a bit that this job is really 24 hours a day, seven days a week. I came to it knowing that was the case, so that's not a complaint - it's just the reality."

He said he also wanted to devote more time in the evenings and weekends to church commitments and family, and had not wanted to delay the decision until the end of 2019 when his departure would overlap with the run up to the next Scottish Parliament elections in 2020.

He said: "Not wanting to leave the Cabinet Secretary in the lurch, I thought this would be the right time to say I was going.

"I've done this job for five years and I don't know that anyone has done it much longer. I'd be the first to say it's a wonderful job, but it's also a heavy job."

Mr Gray, who is married with three grown-up children - a son and two daughters - and two grandchildren, started his career as a clerical officer in the civil service, in 1979.

Read more: Scotland's NHS boss 'fat-shamed' by obesity campaigner

He joined straight out of school - save for a six-month stint working on a farm near his hometown of Linlithgow in West Lothian, where he still lives - but without any grand plans.

"It was a good job to get and I was glad of it, but really my sense of public service grew as my career progressed," he said.

"As a 17-year-old boy, you're neither were mature nor very sensible - your idea of strategy is probably what you're doing that evening. I didn't come in with the ambition to be at the top of anything."

Within a decade, however, he became a senior manager at the Criminal Injuries Compensation Board, and by the time the Scottish Parliament was established in 1999 he oversaw the development of its IT systems.

In 2006, he was appointed Director of Primary and Community Care for the then-Scottish Executive, and went on to hold a series of other directorships, before taking up his current posts in December 2013.

His five-year tenure has spanned both the Scottish independence referendum and the Brexit vote, both polarising events which have contributed to a rise in online abuse against public figures including politicians and senior civil servants.

"I do feel sad about the personalisation of some of the debate on social media," he said. "Personalised attacks I don't think help anyone and I try very hard not to engage or indulge in anything like that because I think it brings a toxicity to the debate.

"Whatever cause you espouse, you harm it by behaving in that way."

Mr Gray, who has spoken publicly about his own weight battle - he lost six stone after taking on his current posts but has "struggled to lose more" - found himself at the centre of a fat-shaming row earlier this year when Tam Fry, chair of the National Obesity Forum, "should redouble his efforts to bring himself into shape".

Mr Fry said the NHS boss - and new Health Secretary Jeane Freeman, a smoker - were setting a bad example.

"To an extent, in a position like this you're fair game," said Mr Gray, adding that he was not personally hurt by the comments but concerned that other overweight people might feel "a bit threatened or 'got at'".

He added: "I come back to the point that if you espouse a cause, including the worthy cause of improving the health of the population or whether it's a political cause, attacking individuals does not in my view enhance the credibility of that cause."

Read more: Health Secretary brands 'cowardly' after shake-up means public will no longer have opportunity to quiz her on NHS 

With his retirement as a civil servant looming, he hopes to adopt a healthier and less stressful lifestyle.

But he also welcomes Scottish Government's ambitions to restrict junk food deals in a bid to reverse Scotland's obesity crisis.

He said: "The habits I need to get into - and maybe I'll get a bit better at when I have slightly less to do - are taking a bit more exercise and eating a bit more sensibly and at sensible times of the day rather than cramming in whatever you can find at 9.30 at night when you're already tired and don't want to spend another half hour making a meal.

"For myself it's more of a matter of personal responsibility than regulation. But I do believe regulation can help, and there's strong evidence for that."