Given the case that a user is presented a modal dialog that displays an installation process (or something similar).
If the process would normally take a few seconds but can potentially take longer, should I offer a "Cancel" button to give the user full control? 

I've seen installers that disable the Cancel button and others that can do a rollback after Cancel is clicked. But what if one does not have the option of a full rollback? Should I ...

* trap the user in the dialog until the process is completed or a timeout is reached
* offer the Cancel button anyways, with the drawback of possibly generating data garbage or an invalid installation
['https://ux.stackexchange.com/questions/79016', 'https://ux.stackexchange.com', 'https://ux.stackexchange.com/users/19337/']
It very much depends on the type of your application the operation it is doing. Ideally user should always be in control, but there are situations when you will want to keep control when you are making critical changes.

Firstly, you must inform user that a following operation might take X amount of time and that she may not be able to use the system. 

![enter image description here](https://i.stack.imgur.com/mYfVN.jpg)

When you tell such a thing, this puts a certain amount of stress on the user. You should try your best to alleviate that stress. Best way is to show the time left, and what exactly is the action you are performing. While doing so, your messages should avoid jargon and meet the target audience's vocabulary.

A windows update may not be an precise example for this situation but it does tell you how Microsoft handled it in Windows 7.

![enter image description here](https://i.stack.imgur.com/jqnOo.png)

Although here Windows can not estimate the time required, it tries to break up the operation in steps so that user has some tangible progress to hold on to. This is very essential for many reasons. I have seen vague progress bars which just run to oblivion without offering any solace to users. You must avoid that.

*Considering your use case, after user feedback, you might want to push the message of delay when the operation does not complete in threshold time. I agree that users would already have started the process, but if most of the times the operation is going to take few seconds, there is no reason to always show a message that they can't use the system. After a few seconds you can pop up and mention this seems to be taking longer than usual. You might need a users opinion on this.*
If there is no safe way for the user to leave the process then you really should make them wait until it is complete. Leaving them with a faulty system is potentially more damaging to the software's reputation than making them wait for an extra 20 minutes for a correct and perfect instal.

However, I assume that they've gone through some sort of process to get to that point (agree to EULA, select instal location, etc), that would be that time to clearly tell them how much time it is expected to take in the worst cases (this will also add a little expectation management giving users who don't experience worst case a pleasant surprise when the process completes more quickly than expected).

If you must offer a "cancel at any cost" option then you will need to clearly message the user about the cost to their system (bad data, disk errors, failing software, etc) with an "Are you sure?" dialogue so that they can make an informed choice. You might also need to include a legal disclaimer depending on the amount of damage you could potentially do to their system.