Deregister window before destroying it
Use proper name for type