Memory leak fix

Break out of the loop when notifications are disabled