The 33-year-old defender played in October's 1-0 home defeat by Ireland in the qualifiers which left Wales third in Group D and ended their World Cup hopes.
"It was just so disappointing missing out on that that I had to think about retirement," Williams told reporters. "I spoke to the people closest to me, I didn't want to retire or anything like that.
"But I felt like it was something that I should've thought about and seen where I was at with club and international football and life in general.
Pogba ready for Man Utd stay if Rangnick kept on as manager - Paper Round
"I did give that a thought, but then I decided I wanted to keep doing it anyway."
Williams said that he had met with new Wales manager Ryan Giggs and his backroom staff earlier this month to help them get familiar with the team.
Giggs, who succeeded Chris Coleman in January, will take charge of his first game when Wales face China in the opening match of the China Cup tournament later on Thursday. (Reporting by Aditi Prakash in Bengaluru; Editing by Peter Rutherford )
Everton settle on Lampard as club's new manager - Report
Vlahovic seals €75 million transfer from Fiorentina to Juventus, takes No 7 shirt