Long-lasting quantum memories: Extending the coherence time of superconducting artificial atoms in the ultrastrong-coupling regime