According to Genesis, Noah waited 40 days after the mountain tops appeared before releasing the raven.
Genesis 8:5 says that the waters continued to decrease until the tops of the mountains became visible. Verse 6 then states that after forty days Noah opened the window of the Ark and sent out the raven. The interval is therefore tied to the appearance of the mountain tops, not to the beginning of the Flood or the duration of the rainfall.
This detail is easy to miss because the Flood narrative contains several different numbers. The account later describes Noah sending out a dove, waiting seven days, and sending it again. Reading the sequence carefully prevents the forty-day interval here from being confused with the forty days and nights of rain in Genesis 7.