Idiom: to hesitate when something is nearly finished
Solution 1:
You're very close:
to falter at the final hurdle
Reasonably recent examples of the metaphor include:
- Liverpool restaurant owner determined not to "falter at the final hurdle" after 'tough' lockdown
[Elle May Rice; MSN]
- Rugby: Ponty falter at the final hurdle: DOUBLE dreams died for Pontypridd against a dominant Llanelli
[WalesOnline]
Solution 2:
To get cold feet
Commonly used for doubts before marriage, but also used for hesitation in completing a task. It has an interesting history, as discussed here: Why do we get cold feet?
Solution 3:
To have a (sudden) change of heart might be the phrase you're looking for.
- It means to have a sudden reversal of one's feelings, intentions, opinions, etc.
E.g. He had planned on retiring and, at the last moment, he had a change of heart.
Or, you might do also with:
To have second thoughts e.g. He had planned on retiring but, at the last moment, he had second thoughts.
And
To waver in the homestretch.
Solution 4:
To opt out/ pull out/ withdraw at the last minute OR at the eleventh hour
Solution 5:
Procrastination covers any first, second, last or any thoughts that you might have.