Implement chapter creation

Ensure that current chapter is closed when a new chapter is created