Nonlinear thermal instability in optically thin plasmas