More than likely yes it was gas cap, either it wasnt selaed all the way or the seal is just worn out on the gas cap. Clear the code and make sure it is tight, if it keeps coming back on i would change the gas cap and see if that helps, if not it might be a leak under the hood
P0440 - Type Powertrain - Auxiliary Emission Controls - ISO/SAE Controlled Description EVAP Purge System Fault Conditions
Cause Engine at idle speed, ECT sensor input over 170°F, then the PCM commanded the EVAP solenoid open and closed and detected that the change in fuel compensation and in the IAC motor position were below a predetermined range
get a new cap and reset the PCM by disconnecting the battery for 20 min while the key is on position. Then shut off key and reconnect battery.