So here’s the problem … you are trying to detect Red after selecting TV, on the TV device. That event never goes on the bus because the TV looks at it and says “this is for me”. This is a known problem and unfortunately there is no workaround.
When the App sends the Red to the TV it goes to the mlgw and then gets forwarded to the TV so it does travel on the ML bus.
However, If you want to simply close the Apple TV when the TV set turns off you can listen to the Release command for TV.