Added function to redirect before turn off the lights