I have an iMac running OS X El Capitan.
I tried to use the disk utility in normal boot to restore two partitions into one but it would exit with an error (exit code 8) and delete the second partition. I then tried to restore the partition in the recovery mode. It seemed to have gone fine but it has got stuck at the last step for ~20 hours now (please see attached image).
I realize it's a foolish thing to have done this without having my data backed up! So, I'm not sure if I should try a hard reset.
Best Answer
In theory, exit code 0 means "No errors found, or successfully repaired" - though I don't know why it has then failed to complete & light the Done button.
Exit code 8 was "A corrupt filesystem was found during a check, or repairs did not succeed." which would not really be surprising if you were trying to work on the partition you were booted from.
Disk Utility is actually running a process called fsck_hfs which has published exit codes on the OS X developer pages
If you cannot normally Quit Disk Utility, force Quit it with Cmd ⌘ Opt ⌥ Esc , or persuade the Mac to restart or shut down normally, then you may have no option but to hold the power key until it shuts down.