I would say that you are trying to exit sub before file is closed. I mean that file is closed by OS asynchronicaly and then OS returns message about completing file operation, but there is no Sub running any more. And this is what triggered Error 5, I beleive.
You should try Empty loop with DoEvents for a second or so, or check if file is closed as a loop condition. only after this you can exit sub.