Try an SMC reset:
How to reset the System Management Controller (SMC) on your Mac - Apple Support
If that doesn't work boot into Recovery and reinstall Mac OS:
Apple Event: May 7th at 7 am PT
Try an SMC reset:
How to reset the System Management Controller (SMC) on your Mac - Apple Support
If that doesn't work boot into Recovery and reinstall Mac OS:
imac not going past progress bar