Slack does this via their Fair Billing Policy [0] and it’s completely automatic. You only pay for active users, so those who go inactive are free.
[0] https://get.slack.help/hc/en-us/articles/218915077-Fair-Bill...
[0] https://get.slack.help/hc/en-us/articles/218915077-Fair-Bill...