Close pdf files after using them
This is against dev
. It includes !1155 (merged) (which is against main
) to avoid memory leaks in pymupdf < 1.19.3.
Also explicitly close lots of pdf files, other minor cleanups.
A future improvement should use some context managers in at least some of these places.