class ActiveSupport::Reloader

def require_unload_lock!

ensuring it will be released automatically
Acquire the ActiveSupport::Dependencies::Interlock unload lock,
def require_unload_lock!
  unless @locked
    ActiveSupport::Dependencies.interlock.start_unloading
    @locked = true
  end
end