'I am with you at present,' said Gandalf, 'but soon I shall not be. I am not coming to the Shire. You must settle its affairs yourselves; that is what you have been trained for. Do you not yet understand? My time is over: it is no longer my task to set things to rights, nor to help folk to do so. And as for you, my dear friends, you will need no help. You are grown up now. Grown indeed very high; among the great you are, and I have no longer any fear at all for any of you.(RK 6.vii.996)
Gandalf is quite right of course. When the four hobbits arrive to discover the evil that has been at work in the Shire during their absence, they handle it quickly and deftly, restoring the quiet anarchy* which had reigned there for as long as anyone could remember. They make not a single misstep. In The Scouring of the Shire the hobbits rescue themselves.
How different this all is from the first steps of their journey when -- as we were discussing recently on Exploring the Lord of the Rings -- they had to be rescued almost every day, by Gildor and his company, twice by Tom Bombadil, and finally by Strider in Bree. Even before they leave Bag End, they are saved from a Black Rider by the Gaffer's ignorance that Frodo, Sam, and Pippin are still there. Then, too, at Bucklebury Ferry, aided by Farmer Maggot and his wagon, they make it across the Brandywine just before the arrival of a Black Rider. So chance, perhaps, or direct intervention save them repeatedly. Indeed the only day they do not have a close call is the day they spend safely under Tom Bombadil's roof, going nowhere. From Bag End to the common room at The Prancing Pony they fail to grasp the caution that is required by the perils they face. They are not yet afraid enough, as Strider points out (FR 1.x.165). Their immaturity, to borrow Gandalf's metaphor, is in keeping with their current romantic and unrealistic understanding of what an 'adventure' is. In the same way, the maturity they gain from the real griefs they suffer on their 'adventures' balances the ending of the tale against its beginning.
* On this kind of anarchy, see Letters, no. 52 (italics mine): 'My political opinions lean more and more to Anarchy (philosophically understood, meaning abolition of control not whiskered men with bombs)....' To be sure, Tolkien is on a bit of a rant in this letter to his son, Christopher, and so his opinion here need not be taken as a considered one, but anarchy of this kind is precisely what we see in the Shire.