Code gets stuck on the last note of the melody after being played

It works now, thank you both alto and Danois! Thank you so much!