How to turn off the LED when Box is closed

Or am i going the wrong way to combine different actions in the loop???