more solid way to completely close the connection