auto-destroy database connections.

- add polling configuration.
- use 'finish' hook to destroy db connection.