Actually, rom experience varies device by device (even for same models, it is possible that you may have more/less stable feeling for rom than others).
so would a CM ROM fix stuff like this?
Yeah there is no memory leak in CM 12.1 right now, that I can assure you.
Stable builds will take a while. Nightly arent bad, I use them too. It really does have a great performance. Never froze in my case, customization is awesome as well.
Now I cannot (and no one can) guarantee same experience for you. I can only give you an idea of what CM 12.1 is now. So->
Its quite very stable. I cant even remember last time I faced an issue on it. Although RAM is not something I bother about, but CM actually leaves my phone with far better free ram than stock.
I Dont have HTC ONE M8 so I dont know how the stock rom was. But on my phone, CM is far better than stock.
I do face some lags. The frequency is somewhere around just 2-5 per day (not more than that definitely, infact I barely notice this).
You can actually push the performance further. Install a custom kernel, get a better governor (my personal fav is interactive v2). Probably overclock it a little (not needed really, but in case you feel like...). There are a lot of tweaks a kernel can do alone.
So bottom line, should I flash the nightly Cyanogenmod ROM, if I'm
looking for stability, speed, and maybe a bit more customization?
Yes. I cannot say for definite that your experience will be mind blowing and stuff. But CM is one rom you must never judge before you actually try. As I said, even its nightlies are very stable given the amount of time they had to correct bugs. As for customization, it has a great theme manager that allows you to control a lot of aspects separately (different theme for notification panel and statusbar, fonts, bootanimations, icons etc etc), so the customization capabilities are ofcourse far better than stock.
In fact, a lot of roms are ported keeping CM as base. CM is known for its stability and speed (and probably minimalism too if you uninstall those pre-installed bloatware apps. The optimized drivers are another great thing), hence it makes porting roms easier. Definitely worth a try.