Merge partitions after windows installation failure After windows failed to install, I was left with my partition, which bootcamp was supposed to remove but it froze and I exited it (probably not the brightest idea ever). So now I have these extra partitions and I'm trying to merge them back into my main disk, like how it was before the windows installation. 

I've tried looking online at what to do but the (-) option that most sites seem to suggest using is greyed out, and would highly appreciate anyone who could help me. 

I've attached screenshots of my disk information. I have the 2017 iMac, with Mojave installed.
This is a very common question. Again, here is the commands you need to enter in a Terminal application window.

I assume the untitled disk0s4 partition was created by the Boot Camp Assistant. If so, then use the command below to remove this partition. Otherwise, skip this command.

sudo diskutil eraseVolume free none disk0s4


The next two commands will remove the disk03 partition labeled OSXRESERVED and return the free space back to the disk0s2 APFS container partition.

sudo diskutil eraseVolume free none disk0s3
sudo diskutil apfs resizeContainer disk0s2 0


There may still be Windows boot files stored in the hidden EFI partition (disk0s1). These files can be removed by entering the commands given below.

sudo diskutil mount disk0s1
cd /Volumes/EFI/EFI
rm -r Boot
rm -r Microsoft
cd ~
diskutil unmount disk0s1