Transcoder doesn't stop when I reject connection

My problem is that when I broadcast with ffmpeg aplication I can't stop the transcoder.

I mean, I have a logic to check if user is allowed to broadcast or not. And if the result is false, i shutdown stream and reject client.
With wirecast it works fine, users only can broadcast when the result is true, if it's false they don't broadcast.

But with ffmpeg even the result of logic function is false, it broadcasts like nothing happens. At least transcoder still on, and when I close connection in ffmpeg the original video gets corrupted, but transcoded videos are fine.