Added support for closing connection