Witr timing

Prophet (saws) told us to make witr the last prayer. This command (amr) is istahbaabi (recommended) not wujoobi (obligatory), since Prophet (saws) himself was seen to pray 2 raka-at after witr

Prophet’s norm was to do witr after tahajjud. But he ordered Hurairah to do it before sleeping.

If you think you are not going to wake up for tahajjud then do witr before sleeping.