Terminate unattended-upgrades or whatever is using apt in ubuntu 18.04 or later editions
The long term solution to your problem is easy:
sudo apt remove unattended-upgrades
There is, in my opinion, no excuse for the poor design of unattended-upgrades. Blocking every software install, and even system shutdown, for hours with an automatically initiated process that a user cannot shut down without risking corrupting the apt database: the mind boggles.
In the short term, you can either wait and hope, or send it a SIGKILL and hope for the best - it will be OK if it is either taking a long time to download, or is stuck because of a missing certificate, faulty connection, or one of the million other reasons unattended-upgrades can trip over its own shoelaces. You may need to manually remove the lock file.
After that, hurry up and uninstall unattended-upgrades to regain control of your computer.
None of these solutions will work if is still running. You will get this error:
"E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?"
You have to stop the service before you can uninstall/remove it. To do that:
sudo systemctl stop unattended-upgrades
Then get rid of it:
sudo apt-get purge unattended-upgrades