We study numerically and analytically the dynamics of defect formation during a finite-time quench of the two dimensional Swift-Hohenberg (SH) model of Rayleigh-Bénard convection. We find that the Kibble-Zurek picture of defect formation can be applied to describe the density of defects produced during the quench. Our study reveals the relevance of two factors: the effect of local variations of the striped patterns within defect-free domains and the presence of both point-like and extended defects. Taking into account these two aspects we are able to identify the characteristic length scale selected during the quench and to relate it to the density of defects. We discuss possible consequences of our study for the analysis of the coarsening process of the SH model. PACS numbers: 64.60.Cn, 47.20.Bp, 47.54.+r, The formation of topological defects in symmetrybreaking phase transitions is a very generic phenomenon in physics, and can be studied analytically and experimentally in different condensed matter systems [1,2]. An example is the onset and formation of stripe patterns in Rayleigh-Bénard convection [2,3]. In this paper, we focus on the Swift-Hohenberg (SH) model [4] for this process. Once above the convective threshold, the system develops a labyrinthine morphology, consisting of domains of stripes which are oriented along arbitrary directions [5]. Between those domains, the system displays several types of topological defects such as grain boundaries, disclinations and dislocations. This structure orders with time basically by grain boundary relaxation and defect annihilation. Similar to other models, in which this coarsening process is self-similar [6], any linear scale of the structure is expected to grow as a power law in time ξ ∼ t 1/z . However, simulations of sudden quenches of the SH equation [7,8,9,10,11,12] have revealed that the observed exponent z is sensitive to non-universal model features such as the quench depth or noise strength. Moreover, different definitions of the length scale have led to different exponents with values reported in the interval 2 ≤ z ≤ 5. This apparent absence of self-similarity in the coarsening is also found in related experiments of electroconvection [13] and diblock copolymers [14]. Multiscaling [10,13] and/or defect pinning [11] have been proposed as being responsible for the scattered value of z, but no general picture has been reached so far about the true nature of the coarsening process.In this paper we consider a complementary, but related aspect of the non-equilibrium dynamics of the SH equation. Namely, we are interested in the formation of defects in a finite-time quench (annealing). Interestingly, some features of finite-time quenches were consid- * Electronic address: galla@thphys.ox.ac.uk † Electronic address: emoro@math.uc3m.es ered in some early works comparing the SH model with Rayleigh-Bénard experiments [15]. Specifically, we study situations in which the control parameter, the reduced Rayleigh number ε ≡ (R − R c )/R c , is swept smoothly over the bif...