Not that I want to be counted wrong, but I translated this as "I'm afraid I have to leave now" which to me is very different from saying "I am afraid of having to leave now". The former is just a way of saying "I've got to go" whereas the latter suggests there truly is a fear of leaving (e.g., something an agoraphobe might say or someone who sees zombies at the door).
But in French usage, it is much more on-target to use "regretter" in expressions of politeness, and we should ordinarily use it to mean "I'm sorry, but . . . " If you say "J'ai peur de" or "Je crains de," you are really suggesting that there might be undesirable consequences from what you have to do. In English, however, "I'm afraid that" is a standard polite way of excusing yourself. The semantic fields (ranges of meaning) overlap, but do not exactly coincide.
I think its about looking for an equivalent in english. when i translated the sentence literally i came up with something like "i have fear of i must leave now" and i thought about what that might relate to in english and came up with "i am afraid i have to leave now" and then i checked this thread to try and understand more about it. sitesurf says above that in french the meanings i am afraid i must leave and i have a fear of leaving are interchangeable in french and must be decided by context. i have had to stop trying to second guess duo and what it wants and just treat each exercise as an opportunity to learn and a prompt to do some research and figure things out when something doesn't make sense :)