Close file after tests added in 945e033a69.

Avoids failures on Windows. Refs #8918.