How to get notified when all threads stop running

I want to run a command to sleep the micro controller when all threads stop running. How do you get notified when all threads stop running (or possibly start a thread to execute the sleep command)?
Thanks

Google “FreeRTOS tickles idle” to find info on getting notified when no tasks are due to run within an application configurable time.