功敗垂成

Idiom

 * 1) to fail when victory is imminent