WebUSB: Always reset the serial terminal when closed (#312)
WebUSB: Always reset the serial terminal when closed (#312)

Refactor code to close serial terminal into own function.

Now when the serial button is used to close the terminal the
terminal itself is reset as well, as it can be deceiving to have
the old content when the micro:bit serial is reset on reconnects.

It also ensures WebUSB is disconnected before clearing the
dapwrapper in case of an error.

bbcmicrobit/PythonEditor,bbcmicrobit/PythonEditor,bbcmicrobit/PythonEditor,bbcmicrobit/PythonEditor