Connect both sockets to a counter set at 2
Each socket has 2 connectors to the counter, and one to the door:-
activate ----> decrement counter
deactivate------>increment counter
The connector to the door from each socket set thus:-
deactivate------> close door
When both sockets are full the counter will have decreased by 2, reaching 0 and firing
Connect the counter to the door:-
activate -----> open door.
This will work as you intend, and even after socketing both gems, if you remove one the door will close. Replacing it will reopen the door
Also target/connect the trapdoor from the counter:-
activate----->open trapdoor