I installed a Samsung 970 EVO 2TB M.2 in my mid-2017 27” 5k iMac and it works great with 4x NMVe speeds. You can use the adapters from the MacBook Air etc… with your 5k mid-2017 iMac … and you will get NVMe 4x speeds with a 4x lane drive . Physically the adapters are the same (different protocols ACHI vs NVMe with same pinout). I haven’t seen this posted anywhere, but the newer sockets on this logic board have an extended shield that can easily shorts to the adapter header. I confirmed with my multimeter. This can short out the power rails and most of the PCIE bus! This would help explain why some people have issues (failure to start and crashing). I used Kapton tape (electrical tape works also, but is not as clean). You want to cover the soldered header pins on the adapter socket on the mating side but obviously not the gold plated card edge pins. See attachment.
Sounds like the battery may be going bad. Loud sounds require more current, if the battery is going bad, the drop in voltage will cause the unit to turn off.