That would be possible using program rules. The program rule will add number of days to the event’s current date and then assign it to a ‘next visit’ data element.
Same, you would use a program rule here to check if it’s the 3rd visit to complete the event and thus close the case.
This is a way you can suggest and schedule the next visit based on a program rule (Note: Only works in Capture, not Tracker capture): Capture - DHIS2 Documentation
Then for “How do we set up a case(the beneficiary) to close after the 3rd visit?”, if this is a specific program stage (separate from 1st and 2nd), you could check “Ask user to complete program when stage is complete”: Capture - DHIS2 Documentation