cocoa: fix deadlock during initialization

Thanks to @wm4 for catching the bug.

Fixes #405