Update terminal.d

Moved scope exit down as this fails to compile on windows.