Fix potential remote console memory leak