I have experienced so many tantrums of other people's children when they surprise their children with home time when the child is completely engrossed in playing. Children are constantly making their own plans and may have been expecting their turn with a toy or be only half-way through building something when they are told to pack up and leave. If it was me I'd be furious too.
I like to give a few warnings so that they can get a feel for how long they have left and I tell them to start thinking about packing up, to get to a checkpoint as soon as they can so they can save their game and if they are waiting their turn with something, now would be a good time to have a final swap over.
I can't recall a time when my kids had a tantrum at leaving time.