Courses which have graded submissions cannot be unpublished (reference).
If your intention for unpublishing is to manage the courses on your Dashboard, you can customise your course list.
Additionally, you can choose to restrict/unrestrict students from viewing the course content (read-only) after the course ends in your course settings.