Ensure file stream is closed.