When will the earth cool/End?

When will the earths core cool to solid rock? Will this happen befor thw sun goes red giant and absorbs the earth?

Click here for a related thread from last week.