How can i set my computer to logout when screen lid is closed

automatic suspend just makes my computer go to a black screen while on which i cannot seem to fix, and i have lockscreen on in settings and i even tried it in terminal. Is it possible i can just find a way to enable logout as soon as my screen lid is closed and opened.

Set Automatic screen lock delay to Turning off the screen.