Though this was a loop of events that were always going to happen, there are still rules to follow. As Hermione explains to Harry in the book, Professor Minerva McGonagall (Maggie Smith) warned her that horrific things could happen if one time travelled irresponsibly. Like, say, killing oneself in either the past or the present, which is sort of referenced in the film during Dumbledore’s own warning to Hermione. His instructions were merely that she and Harry couldn’t be seen by anyone, which also warrants a tip of the Sorting Hat to one Dr. Emmett L. Brown and his views on time travel; but also muddies the waters as to whether or not the young wizards could ever really change anything.
As long as Harry and Hermione have accomplished their goals, and make it back to their starting position by the time they left, without running into their past selves, the timeline will presumably remain undamaged. Which, in turn, closes the predestination loop, and lets everyone return for Harry Potter and the Goblet of Fire.