Windows compatibility

Importing fcntl and termios outside a try block in Windows would cause an error.
These modules are only used inside ioctl_gwinsz, so we can import them there.