There are two ways you can set your IDX link to only display active/closed listings.
Option 1
When you setup a saved search, select Active/Closed under the Status field. If the status field is not available, go to Add a field to the search box and type in Status.
If you are setting up a closed listings link make sure to check this box in Step 2: Select Search Options
Option 2
When you post your link to your website, add the Smart Frame API parameter to the end of the link. Like this, &status=A or &status=C:
https://link.flexmls.com/remdfg0sbrk,6&status=A
https://link.flexmls.com/remdfg0sbrk,6&status=C
This will tell the link to automatically select Active/Closed under the Status field.