First, I hope this has not already happened, but is only a potential concern.
Thus, I'd first address "how to avoid having this happen". As with failing oral prelims and such things, this results primarily from failed communication between the junior person and one or more relatively senior people. Ignoring for a moment department-politics-motivated tenure-vendettas, which do occur, departments are not collectively happy to deny tenure, since it reflects a kind of failure on their part, as well. Although the details of the expectations are different at "research universities" versus "small colleges", departments have expectations. Usually these expectations are communicated fairly clearly, although sometime not too forcefully or formally.
A pre-tenure person should have senior people to talk to about their situation in the department, about expectations, and about progress-so-far. Unfortunately, often there is no systematic implementation of this sort of mentor relationship, and the default is that the dept chair has a yearly talk with pre-tenure faculty. If this defaults further into an absolutely pro-forma, content-free interaction, there is potential danger, especially with a pre-tenure person who is oblivious to exactly these issues.
The worst cases I've witnessed, apart from those involving some political motivations, involved pre-tenure people who were surprisingly disconnected from the department in which they worked. Plausibly doing worthwhile work, but not interacting with local people.
Another kind of disconnection is that the pre-tenure person does receive fairly blunt advice from the dept chair, but decides to ignore it, as though some abstract notion of "virtue" would supercede the dept chair's recommendation!
Nevertheless, even if one has paid attention, it might be that one's research program just didn't quite measure up to hopes... Or there might be political/scientific shifts in the dept which (rightly or wrongly) marginalized your field/work "out from under you". In such cases, the external perception usually is fairly well informed, and the stigma is not too great, and there is hope for other academic opportunities.
If one hasn't paid attention, and, in some sense "rightly" was denied tenure, then this situation is externally understood, too, and it is in this case that one's academic prospects are dim.
Although I've had the good fortune to not need to look for non-academic employment, my several students who have deliberately (or due to vagaries of the job market, grudgingly) found non-academic positions emphasize that it's possibly not your specialized knowledge that you can "sell", but the point that you can learn very complicated things, and do things with them.