dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)

Press Ctrl+Alt+T and do:

sudo dpkg -i --force-overwrite /var/cache/apt/archives/nvidia-340_340.107-0ubuntu0~gpu18.04.1_amd64.deb

This will resolve "the trying to overwrite error" with the mighty force of dpkg. :)

Then run:

sudo apt -f install

to fix if any broken packages.