That's okay, but you're missing an EXIT code when it's finished. All UDF code should have an Exit code and not just Exit either. This has been discussed in the past and shown that on some occassions it can lead to other problems if an Exit with value is not supplied.

I don't think that is the case in this scenario, it returns an error code at the end of the function. Thus the function is ended. I do not believe the function can "hang" in any case scenario however I'd like to hear it if you believe otherwise.