Hidden widget returns when switching between applications

Question as seen above. I have a Reminders script to be hidden if the dock badge returns blank and it does just that but for some reason it returns after I switch between applications. Any help?