close connection when cancel button is clicked