Closing app via keyboard shortcut — should there be a confirmation dialogue? [duplicate]

There are many ways to close apps: mouse-and-click on an 'x' somewhere, choose "Quit" as a menu option, keyboard shortcuts (ctrl-w, cmd-q, alt-f4 etc.)

I notice some apps I use ask me "Are you sure you want to exit?" when I try to close them.

What are the UX guidelines as to when there should be an "Are you sure you want to exit?" confirmation dialogue?