After doing some more tests i come to conclusion that from the moment you see the pdf on the screen and then close it immediately it take sometimes 10 seconds before it executes the next statement, when i leave the pdf a few seconds open on the screen and then close it the next statement will be executed almost immediately !
Originally posted by @dany060954 in #4820 (comment)