Apple - Second monitor turns blue problem

You can try to reset the SMC on your iMac

  1. Shut Down your Mac
  2. Unplug the iMac form the power cord.
  3. Press and hold the power button for 5 seconds
  4. Plug the power cord back in and turn on your Mac.

Also, you can try to reset the NVRAM

  1. Shut Down your Mac
  2. Press the power button and immediately press and hold these keys together: Option Command P and R
  3. Keep these keys pressed down for at least 20 seconds until you can hear the startup sound again
  4. You can release all keys after the Apple logo shows up and iMac boots normally.