Clean up threads when CoreForm is closed