If Hoarding Dragon dies before its second ability resolves, its third ability will trigger and do nothing. Then its second ability will resolve. If you choose to exile an artifact card from your library, it will be exiled indefinitely.