Note:
As a programmer for iOS, Apple does not allow you to exit an application yourself, see why here: exit application when click button - iOS
Anyway, here is the answer to your question.
First, create a SKNode displaying the quit image or text you prefer.
Give it a name:
myQuitImageSKNode.name = "Quit"
Add this SKNode as a child of the camera, in order for this image or text to be at a fixed position on the screen:
myScene.camera!.addChild(myQuitImageSKNode)
Finally, subclass the Scene and override touchesBegan(_:with:)
to check that the user has touched your quit image or text:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let touch: UITouch = touches.first!
let touchedNode = self.atPoint(touch.location(in: self))
if touchedNode.name == "Quit" {
// exit from your app
}
}
Another way to do the same is to subclass the SKNode corresponding to the exit button and override touchesBegan(_:with:)
(this way, no need to check the name).
Finally, to know how to exit the app, look at the first link of this response, or throw an exception, or call fatalError()
... But be careful, Apple does not like this and could decide not to publish your app on their store.