What about when one is trying to sleep or go to bed and temptation comes to them what do you suggest?

Try to go to sleep while in a state of ritual purity. If the temptations still come then go do something productive instead like getting up to make Salat ul Layl