The last BTC will be mined in approx. 2140. But the change is not going to happen overnight. There are a lot of factors that may change within this period, giving miners time to adjust to the new rewarding system and for the BTC network to remain secure. In more than 100 years from now, it seems likely that all these issues will have been solved by Bitcoin Core developers and the wider cryptocurrency community.