Added possibility to close the connection.