Yes, heated towel rails are 100% safe to use anywhere at any time, but it is advised to be responsible as it is a high-end heating device. Most heated towel racks offer safety even if they are left switched on for days and nights.
From another aspect of hygiene, towel warmers are safe, too. Due to their UV sterilization, it fights against germs and bacteria. And, if they don’t have UV sterilization, they will reduce the suitable conditions required for the growth of harmful bacteria as it helps the towels get dry faster.