Fix analyse_elf() leaking file descriptors

This would cause pkg-check -Ba to hold a file open
for every non-elf file in the system due to not
calling elf_end()