In the if statement at the bottom of the script, set finished to True.