I'd cite the Scottish independence referendum as an example of how to do it with the minimum of acrimony and near-zero violence. Although we don't know what would have happened exactly if Yes had won.
I mean, I grant that in the grand scheme of things (and certainly in comparison to how Spain bungled this), you are correct, the UK handled it as well as possible.