Closes #35: Unlock database when all connections are closed