Very happy to help.
Take a look at my modified code. If the MIDI messages work the way you expect them to when they print as debug messages, then you know the logic of the program (with that change to the 0102 conditional) is OK.
Then if the third note is still not being stopped or an extra note is being added, then either there is a problem with the "stop" message format - but why would it only happen with the third note. Or there is a timing issue between the Arduino and the MIDI device - but again, why only in this one particular case?