According to a report in Hindustan times which have quoted some source that it might not have been his own decision, after all. Dhoni was told by the selectors that his time was up as early as September last year. The new selection panel headed by former wicket-keeper MSK Prasad, who took charge in September, had informed Dhoni of their road-map for the 2019 World Cup and that it would be ideal for Kohli to start building his team, the report adds.

source

However, MSK Prasad has moved quickly to deny such rumours.

“There was no pressure on Dhoni to resign from captaincy. It was his personal decision. He informed me during the Ranji Trophy semi-final between Jharkhand and Gujarat in Nagpur,” Prasad told CricketNext, responding to the Hindustan Times report.
MSK Prasad further added “Had Mahi taken the decision one year or even six months earlier, I would have been a bit worried. But I salute him for his sense of perfect timing. He knew that Virat [Kohli] is now a proven customer who has done exceptionally well as a leader in Tests. So it is a correct decision by Dhoni. It showed that he had the best interest of Indian cricket in his mind.”

Prasad clarified more by saying that he had still more international matches under his belt“I still feel he has a couple of years of cricket left in him and as a wicketkeeper-batsman, he can still make an invaluable contribution to the team’s cause. Dhoni’s presence will help Kohli as he now captains across three formats. Had he quit, Virat would have missed out on his immense experience.”

source

But if HT reports supposed to be true then this was not the first time when Dhoni was approached to step down as a leader in Indian Cricket team

Former chairman of selectors had said in September, that Dhoni’s captaincy was under threat over a period of time. Patil had told ABP News back then:

“Absolutely [Dhoni’s captaincy was under threat]. There were lots of discussions that happened regarding that, [and] it’s not like they happened once, they happened a lot. There was a discussion about his one-day captaincy, there were discussions on his finishing… But we selected him because… a time had come, the World Cup had come – [if] you try, before the World Cup, giving a new player the captaincy seat, [you should] give him a good run. But that opportunity didn’t come to the selectors. We didn’t have enough time to experiment.”
Maybe the consequences of the Captaincy turmoil is to be true But Indian cricket officially step into the Kohli era against England and the right decision has been taken with the upcoming ICC events in mind.