python: handle return status of database close and destroy