there is a small magnetic contact on the screen door and frame. If they are out of alignment or part is missing the steps think the door is open and won't close.
The other issue is dirt buildup in the pivots. A healthy dose of WD40 followed by a good lubricant will help if that is the problem.