How do you **gracefully** close Explorer programmatically?

By that I mean, how do you invoke this function programmatically:

![](https://i.imgur.com/D94KL.png)

Edit: Typo in the picture, it should say "Ctrl-Shift-Right-Click" instead of "Shift-Click".