Kee, who spent three months on loan with the Stags in 2015, has openly spoken about his fight with depression, anxiety and bulimia and has not played a game for Accrington Stanley this season after not returning for pre-season training in the summer.
He has now agreed to terminate his contract by mutual consent, saying his health and family are his most important priorities.
A Mansfield Town spokesman said: “Billy has shown tremendous courage in speaking about the challenges which he has faced, and in the process has raised awareness of mental health.
“Billy is held in high regard by the staff here at One Call Stadium, from when he was here on loan. We wish him and his family well in the future.”
Kee bagged 76 goals in 179 league appearances, including finishing as the League Two top scorer with 26 when Stanley won the title in 2018.
Kee told the Stanley website: “Everyone knows my ongoing issues with depression and anxiety and in the summer I made it known about my bulimia which has affected me since I was at Leicester.
“The most important thing is my health and my family, my wife Leigh and two sons and, now I have made the decision, I feel in a better place.
“Accrington will always have a place in my heart and I can never thank owner Andy Holt, manager John Coleman and assistant manager Jimmy Bell enough for everything they have done for me.
“The best moment of my football career was scoring the winner at Luton in the League Two championship season and winning the league. That was so special, to celebrate with the owner, the management, my team mates and the fans.”
Stanley manager Coleman said: “We want to thank Billy for everything he has done, his health is paramount and we want him to get well.
“I class Billy as a good friend and he is the closest person to family as a player.”
Accrington owner Andy Holt added: “In my time here Billy has been one, if not the, best player.
“His golden goals got us over the line in the League Two championship winning season and I was on the phone to him every day during that time.
“We were aware of the problems Billy had from the end of last season and the last six-eight months we have been trying to find a solution.
“We knew Billy’s heart was not in it at this level and he needs to find time and space and a new future for him. He is welcome here anytime.”
Adam Murray signed him on loan from Scunthorpe in January 2015 by which point the impressive Kee had hit 42 goals in 117 games in all competitions.
In 13 games played the former Northern Ireland U21 striker netted goals against Exeter City and Cheltenham Town before leaving Mansfield in April 2015.