By default in i3 there is a key shortcut MOD + SHIFT + e to open bar on top of your screen. If you click on Yes button, i3 terminates. But you have to use a mouse what is not comfortable. I rewrite the shortcut to use dmenu instead of the i3-nagbar.
I use the dmenu utility to launch some applications if I don’t use a terminal. It allows showing a message and options to select one of them. Of course you can filter options by typing.
# vim ~/.config/i3/config
bindsym $mod+Shift+e exec sh -c '[ $(echo "yes\nno"|dmenu -i -p "Do you really want to exit i3?") = "yes" ] && i3-msg exit'