switch context before sleeping