For anyone that’s interested I created a bash script that I run daily from cron:
#!/bin/bash
# Script to permanently delete discourse posts from a specific category that are closed
expect -c "
# This may be $ or # or something else dependent on host environment. Change accordingly.
set prompt \"root@ip-172-31-31-39-app:/var/www/discourse# \"
spawn sudo /var/discourse/launcher enter app
expect $prompt
send \"echo 'Topic.where(closed: true).where(category_id: 11).destroy_all' | rails c > /dev/null\r\"
send \"exit\r\"
"