sudo apt-get upgrade will make it assume yes to all queries.
From the man page:
-y, --yes, --assume-yes
Automatic yes to prompts; assume "yes" as answer to all prompts and
run non-interactively. If an undesirable situation, such as
changing a held package, trying to install a unauthenticated
package or removing an essential package occurs then apt-get will
abort. Configuration Item: APT::Get::Assume-Yes.
So if you make your command look like this
sudo apt-get update && sudo apt-get upgrade -y && sudo shutdown -h 1
To run without risk of new password prompt before shutdown do this
sudo sh -c "apt-get update && apt-get upgrade -y && shutdown -h 1"
it will run and "answer" yes to any prompts you have during
sudo apt-get upgrade.
For more information on the command
apt-get type in a terminal