Demi Lovato is opening up about the days following her overdose and how the "scary" experience left her questioning her future in music.

The singer, 27, who gave an emotional performance of her new song "Anyone" at the Grammys -- penned just four days before her July 2018 hospitalization -- spoke to Andy Cohen on his SiriusXM radio show about her "vulnerability" as she began her journey to getting sober.

The star said "Anyone" represented a "period in my life when everything hit the fan," adding that it left her uncertain about her musical career.

DEMI LOVATO LEANING ON FAITH FOLLOWING NEAR-FATAL OVERDOSE

Demi Lovato performs onstage during the 62nd Annual GRAMMY Awards at STAPLES Center on Jan. 26 in Los Angeles, California. 

Demi Lovato performs onstage during the 62nd Annual GRAMMY Awards at STAPLES Center on Jan. 26 in Los Angeles, California.  (Kevin Winter/Getty Images for The Recording Academ)

"I thought, 'You know, if I ever come back from this' -- because I was still in the hospital and I didn't know -- and I thought, 'If I ever come back from this, I end up going back to music and I'm on stage and I get a first performance, I want it to be at the Grammys and I want it to be this song," she said to the Bravo host (via People).

Cohen questioned if, at the time, she truly thought she may not return to music.

"Absolutely," she replied, adding, "I think as time goes on, I'll be able to give more information or more details and things like that, but...it was a general thought."

"We didn't know what was going to happen. We didn't know how healthy I'd be when I left," Lovato continued. "It was a scary time in my life for sure."

Lovato's performance at the Grammys was her first time back on stage in nearly two years. She opened up about the positive response to her inspiring hit on Instagram this week.

DEMI LOVATO GETS NEW ANGEL BACK TATTOO SIGNIFYING 'REBIRTH' AFTER AUSTIN WILSON SPLIT

"What an unbelievable night. My first time back on stage in almost 2 years. So emotional for me. Thank you for all the love, support and for sharing this moment with me. I love you all," she wrote.

The lyrics to "Anyone" touched upon Lovato's state of mind during that period.

"A hundred million stories / And a hundred million songs / I feel stupid when I sing / Nobody's listening to me / Nobody's listening / I talked to shooting stars / But they always get it wrong / I feel stupid when I pray / So, why am I praying anyway? / If nobody's listening," she sings in the ballad.

"Anyone, please send me anyone / Lord, is there anyone? / I need someone / Anyone, please send me anyone / Lord, is there anyone? / I need someone."

Also in the interview, Lovato touched on her love life and how her parents reacted to her declaring she was "sexually fluid." She opened up about it in the YouTube documentary about her life titled "Simply Complicated" in 2017.

SUPER BOWL LIV PROP BET SETS LINE ON DEMI LOVATO SINGING NATIONAL ANTHEM IN UNDER TWO MINUTES

"I didn't officially tell my parents that I saw myself ending up possibly with a woman until 2017," she said. "It was actually emotional, but really beautiful. After everything was done, I was like shaking and crying. I just felt overwhelmed."

The star said her "incredible" parents were "so supportive."

Lovato touched down in Miami, Fla. this week, gearing up for her performance at Super Bowl LIV, where she will be singing the national anthem.

CLICK HERE TO GET THE FOX NEWS APP

And she's no stranger to performing in front of audiences at major sporting events. Lovato opened an NFL Thanksgiving Thursday game in 2008, Game 5 of the MLB World Series in 2011, Game 4 of the MLB World Series in 2012, Game 4 of the MLB World Series in 2015 and she even graced the ring when Conor McGregor boxed Floyd Mayweather in 2017.

Fox News' Jessica Napoli and Julius Young contributed to this report.