If you instead identified as a parent, as a hobbyist programmer, as a rock climber, as a learner, as a meditator, in essence as anything that is not directly tied to your occupation, you don't have anything to worry or be sad about.
This is hard, capitalism has forced us to identify with occupations, and then when it gets automated you feel a loss. But it's inevitable that this will need to be the outcome, so the sooner you start building an identity outside of your livelihood the sooner you will feel at peace.