Thermodynamic stability of residually trapped carbon dioxide in geological carbon sequestration