Photonic crystal structures are of great practical interest because they allow light to be strongly confined and manipulated at scales on the order of one wavelength. Useful photonic crystal devices have been demonstrated, but these structures can be improved upon by using better simulation tools. Topology optimization is presented here as one approach for designing improved photonic crystal structures. Topology optimization is a numerical technique that uses nonlinear programming techniques and design sensitivity analysis by the finite element method to calculate improved photonic crystal structures. The general technique is outlined, and the case of a waveguide termination in a square lattice rods-in-air photonic crystal is demonstrated. A compact waveguide termination is designed that shows a fivefold increase in power incident upon a target area over a simple termination.