My method should fix the problem and will work just fine 99% of time. But please be mindful that if the update process is running and you killed the process in the middle of package installation, you might end up with broken system. In such cases, don’t panic, just follow the below guide to fix it.
Source: LXer – How To Fix “E: Could not get lock /var/lib/dpkg/lock” Error On Ubuntu