Fix potential memory errors with note player.

Seems unlikely, but if the event firing stuff is off, it could trigger the
issue (#5502) and/or a possible memory leak.