Hello Andreas,
Have you checked the integrity of the data?
Another thing to check is your procedure. When Period End is finished and you OK the information message, the program will close the function itself. If you are trying to close it as well, the program may not know how to interpret that.