The reward for a miner when it finds a new block is already composed of the subsidy (currently 12.5 BTC) and sum of transaction fees that the miner included into the block. If you look at the blockchain right now, the minimum transaction fee sum of last 3 blocks was 0.5075 BTC. This means that much sooner than before last bitcoins are mined (i.e. reaching 21M cap) the part of the reward from transaction fees will be much greater than the subsidy itself.
After next halving, the subsidy will be 6.25 BTC, then 3.125 BTC, ... and after 7 halvings, the subsidy will be less than 0.1 BTC. And this is going to happen in cca 30 years (while the last bitcoins will be mined in more than 120 years). So much sooner than what you are referring to, the transaction fees will become major dominant part of the reward.
At any point of time, miners will only stop mining if that stop becoming profitable for them. So currently, the reward from a block is about 12.5-14 BTC, which translates roughly to $31k per mined block (at current difficult over 700G). So many different scenarios can play out in 30 years. For example, price per 1 bitcoin can raise from $2.4k to $50k. At that point, if subsidy is 0.1 BTC and sum of transaction fees are just 0.5 BTC, you've got 0.6 BTC total reward, which would translate to $30k. That might be enough if difficulty stays at 700G and prices of electricity stagnate as well, or of hardware mining chip technology advances and provides better cost per hash (very likely to happen), or it might not be enough if electricity cost or difficulty goes up a lot, ...
But every transaction in the ecosystem already has to pay a fee. That will become more and more important over time as the subsidy goes down. That does not mean the cost for end user will go up. It may temporarily, but new scaling solutions are coming and are promising to reduce the need for on-chain transactions for small payments.
Also, the blocks are going to be bigger, which means more transactions will be allowed to a single block, which could mean higher reward for miners from the fees.
So many different scenarios are possible, it is impossible to predict what exactly will happen, but the sole fact of lowering subsidy is not a big problem. To answer your final question - yes, the system still can work as it is now, even after 30 years, and even after all bitcoins are mined.