I recognized this was a terrible pattern. I began shutting off the tv when I was going to bed. Eventually I moved the television out of my bedroom.
This is learned behavior and it can be unlearned. There's one simple solution to the problem posed in this article. Get the tv out of your room; it's not doing anything positive for you and I'm fairly certain you won't crave to have it back once it's gone.