Same answer as the one given by twistor59, but written in a differential form language. By definition, F=dA, so
d(A∧F)=dA∧F+A∧dF=F∧F
where we used dF=0 (because d2=0).
Same thing in the non-abelian case, as suggested in a comment by ruifeng14. By definition, F=dA+A∧A, so
d(Tr(A∧dA+23A∧A∧A)=Tr(dA∧dA+2dA∧A∧A)
=Tr(F∧F)
where we used the cyclicity of Tr to rearrange the terms like Tr(A∧dA∧A) and to obtain the vanishing Tr(A∧A∧A∧A)=0.
The expression Tr(A∧dA+23A∧A∧A)=Tr(A∧F−13A∧A∧A), which reduces to A∧dA=A∧F is the abelian case, is called the Chern-Simons Lagrangian.