Fix unclosed handles in get_process_memory