Should I use atexit to close db connection?
Firstly, an alternative:

import MySQLdb, contextlib

def main():
    db = MySQLdb.connect( .. )
    with contextlib.closing(db):
         do_thingy()


The database connection will be closed after the with block even in the case of exceptions.

The primary problem created by atexit is in any attempt to reuse that code in question. It will only release the database connection when the entire program exits. That's fine in the case where this function is your entire program. But at some later point that my cease to be the case. 

If you really want the database connection to be closed at the end of the function, its clearest if you write code that does that rather then assuming that this is the only function called in the program.

There really is not much of saving to use the atexit route. I think the clarity in the "with" method is worth the extra level of indentation. Additionally, you can use this same technique anywhere in code not just in a main function.