Some research indicates post-workout is the best time. Your body is primed for nutrient update and utilization after a good workout, so it makes sense to feed the right fuel.
Now, my question to you is why are you taking a shake at bedtime? Shakes are not a very good bedtime meal because they digest too quickly I'd take a shake post workout, and then at bed have cottage cheese or some other kind of whole protein that doesn't digest in 2 hours.