Leave the temporary directory before cleanup
Leave the temporary directory before cleanup

On Windows, there was some fairly nasty behaviour where the interpreter
would crash without any error or message being printed if we tried to
delete the temporary directory (via the context manager's __exit__
method) before we did `os.chdir(previous_dir)` to leave it.

Here we simply invert the order of the `try` and `with` blocks to make
sure that the swap back happens before the context manager cleans itself
up.

See also further discussion in #1194.

Co-authored-by: Boxi Li <3238121b9c59c7207bf1fec821af6ae73f13ac08@gmail.com>

cgranade/qutip,cgranade/qutip,qutip/qutip,qutip/qutip