In most cases, a simple sudo dpkg --configure -a resolves everything and takes only a few seconds to run.
Sometimes dpkg is stuck because a specific package is corrupted. In most cases, a simple sudo dpkg --configure
Remove the lock files:
After removing locks, always run the configure command again: In most cases