While we're looking at the exit behaviour, use the recfile close method now instead of f.file.close().