Fix possible deadlock in panic