Ahead of curfew ending, bombs kill 40 in Baghdad