Fix race condition in get_buttons.