I got somehow similar problem with word doc. printing. A msg. shows up asking if you want to quit the word without printing. So I put a couple of seconds time delay before the word quits and it worked fine. The problem is that printing a doc. or saving a file takes time and the processing doesn't wait.
There might be a better way to avoid this.