hadnle closing connection without having to restart the application