Deductions & credits

The gain is what your net proceeds when you sell minus what you paid and minus any capital improvements. I’m not surprised that a change in visa status is not specified in the list of reasons for partial exemption since relatively few  would have that problem. But you are forced to move and that is in keeping with the intent of the law.