Are you running on the simulator?
If so, that's perfectly normal behaviour - remember your code is running mostly as a callback. From a brief look that's the same behaviour I've experienced for years - your code is terminated by Messages.
Does it work on device?
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: