refactored the connection close handler
added terminal resizing based off window size