Make things a little less racey

This fixes raciness concerns raised (hrhr) by @fbogsany. MRI should be
fine, but there's still an element of raciness in other Rubies due to
the inability to use mutexes in signal handlers (or without any proper
memory barriers).