WebUSB: Refactor code to close serial terminal into own function.
WebUSB: Refactor code to close serial terminal into own function.

Same code was in 3 different places.
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.

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