From quick test $wp_query->get_queried_object_id()
should get page’s ID when that page is set to be posts page.
This is likely the issue of timing it late enough that it is available, but early enough so that loop of posts doesn’t interfere. I’d try to capture it early (in template_redirect
hook or around that) and store in global variable to use later.