fix msvc warnings
postgres provider:
- fix connection cleanup from threads
- fix disconnection of style functions

fixes #9280 (adapted PR#1051)