I dont think adding sleeps inbetween dialogue matters much, im willing to bet that me and every other guys doing quests just spam their spacebar
To close the quest completion window, i guess u could just check to see if the X button is visible or something
Before starting up another script you should always refresh your script selector, that way there shouldnt be an issue