Is it possible to turn off external displays when I close the lid of my macbook? By default, when I close the lid of my macbook, the external display becomes the primary. It is annoying because I have to plug out the cable and charger to turn it off but I'd like that whenever I close the lid of my macbook, it puts the macbook to sleep and turns off external display? Is it possible?
As macOS doesn't provide a way to shutdown all screens by closing the laptop lead, which is a shame, you can put the laptop in sleep mode and also set security parameter to lock it immediately when it goes to sleep so you can leave once the screen is black.

If you have a MacBook with Touch Bar, you can also add the sleep icon to it :  

I put it on the left to be sure not to touch it when i hit the fingerprint sensor or the delete key...

To modify the touch bar, go to system preferences/keyboard and you will find a "customise touchbar" on the bottom right corner.