This is the recommended advice from Ubuntu Teams (found here and previously posted as a comment by Guillem)
# allows you to kill the processes
sudo fuser -vki -TERM /var/lib/dpkg/lock /var/lib/dpkg/lock-frontend
finishes pending installs
sudo dpkg --configure --pending
I followed this and it worked perfectly after a failed grub update.
From the Documentation linked above:
Removing the dpkg lock files is never a correct solution, as dpkg uses region locking (on existing files) which are bound to a process, so once the process finishes or is killed the lock is automatically released (and dpkg itself never removes the lock file). The presence of the file does not mean that the lock is currently being held, and removing them can most probably cause dpkg database or filesystem corruption. If there is ever a need to override the locks, then it is always preferable to kill an active running dpkg over ever removing the lock files, as dpkg is supposed to be resilient against abrupt system or process crashes or termination, and any issues stemming from those would be considered serious problems in need of fixing.