To earn a certificate you will have to upgrade to the verified track by the course upgrade deadline, and reach a passing score before the course end date. It is not possible to earn a certificate in a course that has ended.
When the course is ending soon, you'll see the end date posted on the course homepage on the right side under Upcoming Dates: