Viral DNA Retention and Ejection Controlled by Capsid Stability