To teach the Sensor its closed position, go to the Home + Security app's dashboard, tap your product's tile and then press "Calibrate".
In order for the calibration to be effective, you have to close the door or window on which the Sensor is placed. Calibration takes approximately 2 minutes.
Updated