Sometimes window alarm sensors can go off unnecessarily. To prevent this from happening, make sure the sensor and the magnet are aligned correctly and are close enough together that contact is assured when the window is closed. It might take some tweaking to get it right.