It's interesting that the wording is such that the referee may end the advantage period inside the five seconds if an advantage has not occurred, but may not end it within the five seconds if an advantage has occurred.
So the referee must wait for five seconds to deem that an advantage has accrued but can deem that an advantage has not accrued in, say, 2 seconds.
That seems to mean that he can't consider it an advantage if, for instance, the team of the fouled player gets possession from the foul and end the advantage period. He must wait five seconds. In theory, the attacking team could have two shots back off the post and a great save from the keeper in that time and still get a free.
It also means that if there's a subsequent foul within the five seconds, he can't start a new advantage, but must stop for the original foul.