washer will not spin unless lid is opened and shut

this is stacked unit. washer will drain but not spin unless lid is lifted open and then shut. I figure either lid switch or possibly a solenoid. any ideas?