Use the sharedApplication delegate instead of NSApp's delegate. Fixes #16795