Connection bug fix

Fixed connection bug while first-time connecting to database - it was
automatically shut down