I did input this into the config.php and that worked. Uninstall button showed up next to essential plugin.
That is the clean method.
However, after deleting it and updating the database, essential theme was still there. Deleting Essential directory manually also gave the same response.
Yes, as you discovered telling Moodle that the theme is no more needed and removing the theme from the code tree are two separate steps. They need to be executed in that order, resp. after step 1 Moodle will tell you when to do step 2.
It seemed that the essential theme was being deleted and after updating the database, the theme was back.
Do you say, Moodle "remembers" the code of the plug-in and dump it back?
What settings must I change so that this theme does not come back?
No "settings". It is the procedure described above.