It takes maturity and decisiveness to recognize when a startup's core idea isn't going to work. In cases where any pivot wide enough to get into different lane is essentially a whole other business, it's often better to just shut down. Even if the last desperate pivot starts to work, you often have some team members and investors who aren't a good fit for the new focus and, worse, the 'new' business that's finally starting to work is almost out of money and the cap table is messed up. It's usually better to shut it down and reboot cleanly.
Founders who've successfully raised millions and executed well are usually quite fundable, even if their first startup didn't work out. Sometimes the timing is wrong or the market evolves differently. The key is how well you think, execute and communicate through both the windup and the wind down.
Major pivoting is almost always a really bad idea. (I admit I'm doing a bit of weaseling using the "major" qualifier, but when I searched for examples online, a lot of the ones that came back weren't major pivots, just slight refinements of focus to find better product market fit). Pivoting usually carries a lot of baggage - better to just give the money back and start afresh most of the time.