I have to say it is unlikely there will be sanctioned euthanasia for age related decline or dementia. The practicalities of implementing such a system are probably prohibitive, the primary problem being ending the life of someone without the capacity to tell you that is what they want. This is in some ways insurmountable, because although your 50 year old fit and happy self would definitely want to be euthanised if they had severe dementia, how do we 'know' that this same person who now has severe dementia also wants to die?
It is similarly unlikely there will be a test which can predict imminent dementia well enough that you would be happy to euthanise yourself while you still have decision making capacity.
As others have said, what you can do is have some legal document which explains your wishes if you lose capacity to make decisions, where you specify the avoidance of life prolonging therapies, intensive care, resuscitation etc. The other thing which is important is having someone that will take over medical decision making whom you trust will act according to your wishes, in the event you lose decision making capacity. Another aspect of this is making sure friends and family are aware of your wishes. This is a kindness to them as much as anything, so that when the time comes to withhold or withdraw medical treatment, they don't have to ruminate on whether it is the right thing to do.