How to setup cron trigger in CiviRules extension
You can set the Membership status rule to end date as 40 days for pending status. But i am not confident that pending memberships are actually processed by 'Update Membership statuses' cron job.