Terminating codeblocks proerly