Fix #5390, crash on Exit on Windows.