Move signal channel closing to defer function and stop notification before that.