Don't cast cleanup functions, provide wrappers instead (PgSQL, SQLite3).