A better option is to, on Day 39 when you're done (so at 21 or 22), type "jump Day38" on the console. Don't mind the number on the day, this is just the new day function after day 38. This will start the day with all switches reset and prevent "weirdness".You press shift o and type it in then sleep then type it in again.
The problem causing the issue is that in the code in the bedroom, there is a condition that reads if day >= 37 and day < 40: but the next condition is if day >= 41 and day < 44 so day 40 isn't handled correctly and it falls through to a return. It's a simple fix.
Edit:
Bah, already fixed, of course. I knew I should have read ahead!