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

Was the number of elements in the array that was too short all you had to change?

a7