Genesis 7:16

And they that went in, went in male and female of all flesh, as God had commanded him: and the LORD shut him in.

And they that went in, went in male and female of all flesh,.... These pairs were not two males or two females, but one male and one female; so they were coupled for the propagation of their species, which was the end of their entering into the ark, and being preserved:

as God had commanded him: Noah, who took care, as they entered, that there were so many of a sort as was enjoined, and these were male and female:

and the LORD shut him in; or shut the door after him {l}, he being the last that entered; and which he could not so well shut himself, at least so close, as was done by the Lord, or by the angels; and this was done to keep out the waters, and all within in safety; and to shut out others, and preserve Noah from the rage of wicked men, as well as the violence of the waters: some {m} have thought that not so much the door of the ark is meant, as the way to it, the pensile bridge which was necessary for the creatures to enter the ark; which being carried away by the force of the waters near the ark, that not being joined to it, precluded all access of the scoffers, whose scoffs were soon turned to lamentation and howling.

{l} wdeb "post ipsum", Vatablus, Tigurine version, Cocceius, Schmidt. "Pone eum", Piscator.
{m} Scheuchzer. Physica Sacra, vol. 1. p. 45.