Change your while loop in loopIt() function in this:
while True:
if TRACK_IS_PLAYING:
for i in range(0,8):
MIDI_OUT.send_message(clock)
time.sleep(interval)
Now, will sending your message only when TRACK_IS_PLAYING is set to True