My personal opinion is that such a career path can contribute a lot to mathematics, because such candidates can often be informed by a more practical or utilitarian focus in their mathematical research, which provides providing an important and invigorating perspective. For example, for someone to arrive at hard-core mathematical research in financial mathematics after having actually worked in investment banking would be extremely useful. And surely there is a similar situation with many other areas of applied mathematics. In areas tending towards pure mathematics, however, probably it becomes more difficult to make the case that the time spent away from research mathematics was beneficial.
In any case, a person applying for a position from such a situation would naturally have a disadvantage in terms of publications and research accomplishments in comparison with the competing candidates. If the idea were to take a non-academic position with the goal of eventually returning to academic research, therefore, then it would seem advisable to keep up one's research as best as one can. Even a publication or two would be fairly convincing evidence of one's true mathematical nature.
I do know several examples of people who spent a long time away from academic mathematics and then returned to a successful academic career in pure mathematics (and even in set theory!). I know of several mathematians who had entire careers in business or computer software before returning to academic research and becoming tenured professors. So indeed it is possible. But surely this is far from usual, and certainly the more typical pattern is that once someone leaves mathematical research, unfortunately, they do not return.