Short answer: gnome-terminal only prompts you if a foreground process is active and the configurable option
confirm-close is true.
The long answer is:
As you can see in source code, gnome-terminal checks vor
TERMINAL_SETTING_CONFIRM_CLOSE_KEY when it receives a window close request.
Here you will see that it maps to
You may get or set this setting using
gsettings get org.gnome.Terminal.Legacy.Settings confirm-close
gsettings set org.gnome.Terminal.Legacy.Settings confirm-close true
The source of the function that decides if a confirmation is needed is here.
gnome-terminal only asks for a confirmation if confirm-close is true and if a foreground process is active in at least one tab. So if you want to always be asked before closing a gnome-terminal window you have create one tab and start a foreground process in it, i. e.
ping -i 10 127.0.0.1
Furthermore you have to activate tabs:
menu -> terminal -> settings -> open new terminal in: tabs
You may create a gnome-terminal profile which starts such a process automaticly. So you can configure gnome-terminal to start that profile on startup or you may easy start it yourself selecting
file -> new terminal -> your profile
from the menu.