Fix nipapd sqlite file leak

Sqlite connection was not properly closed. Additionally, an open instance in the main thread would prevent others from being closed.

Some links that led me to this:
http://stackoverflow.com/questions/10332253/sqlite-persisting-file-handles-in-wal-mode
https://docs.python.org/2/reference/datamodel.html#object.__del__

Note: as per this commit, apache still leaks open file handles