I had a problem with a document that was failing after an apparently successful script execution. There was nothing complicated in the script (no QVD files or input fields) and it completed in 37 seconds. The log file gave no errors and the final line read "Execution finished.".
However, when I clicked "Close" it gave the script failed message and forced me to reload old data.
I tried restarting QlikView, deleting the log file and restarting my computer, but the problem remained.
In the end, I opened the document "Without Data" and the problem has disappeared. I do not know what caused it, but opening without data fixed it.
I am using QV Desktop 11.20 SR5 and posting this in case anyone else has similar issues.