Fix database connection leaks

This fixes a couple of database connection leaks that were causing deadlocks in Pro.

Verification Steps:

- [x] Start `msfconsole` with database support
- [x] Try to get a psexec session with a bad password:

        use exploit/windows/smb/psexec
        set RHOST 192.168.1.105  # A windows target
        set SMBPass wrongpass
        set SMBUser administrator
        exploit -z

- [x] VERIFY: Exploit failed
- [x] Enter IRB shell: `irb`
- [x] Run this nifty command to show ActiveRecord connections associated with framework threads:

        ActiveRecord::Base.connection_pool.instance_variable_get("@reserved_connections").map {|key, val| thread = Thread.list.find {|t| t.object_id == key}; "#{key}: #{thread ? "#{thread[:tm_name]} #{thread.inspect}" : "Unknown" }" }

- [x] VERIFY: Only one connection exists.  If a second connection associated with the ModuleCacheRebuild thread exists, that's ok - you are a faster typer then me ;)

- [x] Exit out of IRB.  `exit`
- [x] Get a session.  For example, on Metasploitable2:

        use exploit/unix/ftp/vsftpd_234_backdoor
        set RHOST 192.168.1.101  # A Metasploitable target
        exploit -z

- [x] VERIFY: You get a session
- [x] Drop back into irb: `irb`
- [x] List the ActiveRecord connections:

        ActiveRecord::Base.connection_pool.instance_variable_get("@reserved_connections").map {|key, val| thread = Thread.list.find {|t| t.object_id == key}; "#{key}: #{thread ? "#{thread[:tm_name]} #{thread.inspect}" : "Unknown" }" }

- [x] VERIFY: Only one thread exists.