crow before one is out of the woods

[crow before one is out of the woods] {v. phr.} To be glad or brag before you are safe from danger or trouble. - Usually used in negative sentences, often as a proverb, "Don't crow before you are out of the woods."

John thought his team would win because the game was almost over, but he didn't want to crow before they were out of the woods.

Often used in a short form, "out of the woods".

Mary nearly died during the operation, and she is not out of the woods yet.