Fix ruby21 mutex lock within trap

DTA failed yesterday. It's important we get this out.
Fixes https://bugs.ruby-lang.org/issues/7917. Inspiration from https://github.com/websocket-rails/websocket-rails/commit/064dc912ecde718ab2d8ec79382e89ea361de7af