The irrational act isn't locking the fridge, it's snacking at midnight--you gain weight, use up food, and get less sleep.
You don't have to result in locking up your food at night, just stop eating during that time.
Locking up the fridge at night is perfectly reasonable if you want to lose weight.