Only set expiration date when the checkbox is selected

Fix #4823