Its interesting. Note that when I deleted the HP printer from the list of printers on the printer and scanner list in System Preferences it said the printer is trying to print. Remember that I had disconnected the printer from my laptop while it was yet to complete a print task. This probably triggered this behaviour. I think its important to complete the print command or abort it before disconnecting the printer from the laptop to prevent this event from recurring.
Thanks Pink Panther for helping with the issue.
The System log mentioned this
Sep 11 23:00:02 Apples-MacBook-Pro kernel[0]: process com.hp.devicemod[226] thread 1798 caught burning CPU! It used more than 50% CPU (Actual recent usage: 89%) over 180 seconds. thread lifetime cpu usage 90.015745 seconds, (89.457739 user, 0.558006 system)