remove_meta_box for all post types doesn’t seem to work

Remember Apple’s “Goto Fail”?

Similar situation:

Your code actually does this, when indentation is corrected:

 foreach ( $post_types as $post_type )
        remove_meta_box('trackbacksdiv', $post_type, 'normal');

 remove_meta_box('postcustom', $post_type, 'normal');
 remove_meta_box('authordiv', $post_type, 'normal');
 remove_meta_box('postexcerpt', $post_type, 'normal');

So, it should does the job for trackbacksdiv, but not for the rest because the function calls are outside of the foreach and $post_type is not defined.

If you replace $post_type with post it works, because..well, the function arguments are complete.

Wrap your foreach in { } and try it again.