Host stuck in build mode when "unattended: <hostname> is Built!"

We've noticed this issue for some time now: a host would get stuck in build
mode even after the OS installation has finished and the GET
"/unattended/built" was received. It is reproduced once every few
provisions and I'm not sure what causes it. Sometimes the GET
"/unattended/built" fails, but sometimes it finishes successfully and the
build flag would still be set. The log bellow is for a host that installed
successfully, but remained in build state:

Started GET "/unattended/built?token=<token id>"
Processing by UnattendedController#built as /
Parameters: {"token"=>"<token_id>"}
Found <hostname>
unattended: <hostname> is Built!
Completed 200 OK in 105ms (Views: 0.2ms | ActiveRecord: 18.5ms)

We are using foreman 1.8.2 to provision (PXE) RHEL 7.2. I don't think it is
relevant, but I'm going to mention that we use curl instead of wget to GET