Frank,
There is no harm in pressing the Cancel button during that operation. Compacting local history is really a pruning operation, based on local history settings, rather than altering the history files. This is a base eclipse function.
The length of time might indicate that you have a very large history for that workspace. You can alter history settings via Windows->Preferences->General->Workspace->Local History. You can reduce any of the settings to limit the history space still further, which should have an impact after the first shutdown following the change. You can, alternatively, uncheck the “Limit history size” option, which will simply stop compacting the history at shutdown, though your history can then grow to the available disk space, in theory.
To check if this is the problem, you can always just rename the history folder (to effectively clear it, without getting rid of your history – a new folder will be created if you make source changes) to see the effect on your workspace shutdown. The history folder is in your workspace at .metadata/.plugins/org.eclipse.core.resources/.history. Note that you will need to rename the file back again to be able to access the history from the workbench.
Please let us know if these suggestions help.